Ticker

6/recent/ticker-posts

Ad Code

Responsive Advertisement

menu无法调用updateActiveName和updateOpened

Menu菜单是动态生成的,在created和watch里面调用updateActiveName和updateOpened,总是报无定义。
image.png

<Menu  ref="sideMenu" width="auto" theme="light"  v-for="(menuItem, menuIndex) in treeModule" :key="menuIndex" :open-names="openItems" :active-name="activeItem">
created() {
    this.openItems = [4];
    this.activeItem='4-1';
    this.$nextTick(() => {
      this.$refs.sideMenu.updateOpened()
      this.$refs.sideMenu.updateActiveName()
    });
  },
  watch: {
    // 监听展开的子目录,更新
    openItems() {
      this.openItems = [0];
      this.activeItem='0-1';
      this.$nextTick(() => {
        this.$refs.sideMenu.updateActiveName()
        this.$refs.sideMenu.updateOpened()
      });
    },
}

Enregistrer un commentaire

0 Commentaires