vue保持侧边栏激活状态

使用标签时,想要保持侧边栏的激活状态,使用@select方法获取当前选中路径,存储到sessionStorage中,创建页面时获取即可

:default-active="activePath"  router unique-opened @open="handleOpen" @select="handleSelect">

    ......

data() {

    return {

        activePath:''

     }

}

methods:{

    handleSelect(index) {

        window.sessionStorage.setItem('activePath', index);

    },

}

created() {

    this.activePath = window.sessionStorage.getItem('activePath');

},

你可能感兴趣的:(vue保持侧边栏激活状态)