|
@@ -130,26 +130,29 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
- defaultActive(value) {
|
|
|
|
- const item = this.items[value];
|
|
|
|
- if (item) {
|
|
|
|
- this.activeIndex = item.index;
|
|
|
|
- this.initOpenedMenu();
|
|
|
|
- } else {
|
|
|
|
- this.activeIndex = '';
|
|
|
|
- }
|
|
|
|
|
|
+ defaultActive: 'updateActiveIndex',
|
|
|
|
|
|
- },
|
|
|
|
defaultOpeneds(value) {
|
|
defaultOpeneds(value) {
|
|
if (!this.collapse) {
|
|
if (!this.collapse) {
|
|
this.openedMenus = value;
|
|
this.openedMenus = value;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+
|
|
collapse(value) {
|
|
collapse(value) {
|
|
if (value) this.openedMenus = [];
|
|
if (value) this.openedMenus = [];
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ updateActiveIndex() {
|
|
|
|
+ const item = this.items[this.defaultActive];
|
|
|
|
+ if (item) {
|
|
|
|
+ this.activeIndex = item.index;
|
|
|
|
+ this.initOpenedMenu();
|
|
|
|
+ } else {
|
|
|
|
+ this.activeIndex = null;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
getMigratingConfig() {
|
|
getMigratingConfig() {
|
|
return {
|
|
return {
|
|
props: {
|
|
props: {
|
|
@@ -287,6 +290,7 @@
|
|
if (this.mode === 'horizontal') {
|
|
if (this.mode === 'horizontal') {
|
|
new Menubar(this.$el); // eslint-disable-line
|
|
new Menubar(this.$el); // eslint-disable-line
|
|
}
|
|
}
|
|
|
|
+ this.$watch('items', this.updateActiveIndex);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|