update Menu

update Menu
This commit is contained in:
梁灏 2016-12-08 13:29:49 +08:00
parent 0acdae1983
commit ab673ebc6b
3 changed files with 24 additions and 2 deletions

View file

@ -24,7 +24,10 @@
type: [String, Number]
},
openKeys: {
type: Array
type: Array,
default () {
return []
}
},
accordion: {
type: Boolean,
@ -81,6 +84,14 @@
item.active = item.key === this.activeKey;
}
})
},
updateOpenKeys (key) {
const index = this.openKeys.indexOf(key);
if (index > -1) {
this.openKeys.splice(index, 1);
} else {
this.openKeys.push(key);
}
}
},
compiled () {
@ -92,6 +103,11 @@
this.updateActiveKey();
this.$emit('on-select', key);
}
},
watch: {
openKeys () {
this.$emit('on-open-change', this.openKeys);
}
}
}
</script>