我在代码中动态设置了open-names,但是不起作用?
如:store.js
{
state:{
menu:{
activeName:'4-1',
openNames:['4']
}
}
}
MyComponents.vue
<Menu
theme="dark"
:active-name="menu.activeName"
:open-names="menu.openNames"
@on-select="onSelect">
<template v-for="menu in menu.list">
<MenuItem v-if="!menu.children" :name="menu.id" :key="menu.id">
<Icon :type="menu.icon" :key="menu.id"></Icon>
<span class="layout-text" :key="menu.id">{{menu.name}}</span>
</MenuItem>
<Submenu v-if="menu.children" :name="menu.id" :key="menu.id">
<template slot="title">
<Icon :type="menu.icon"></Icon>
<span class="layout-text">{{ menu.name }}</span>
</template>
<template v-for="child in menu.children">
<MenuItem :name="`${menu.id}-${child.id}`" :key="child.id">
<Icon :type="child.icon" :key="child.id"></Icon>
<span class="layout-text" :key="child.id">{{ child.name }}</span>
</MenuItem>
</template>
</Submenu>
</template>
</Menu>
import { mapState,mapActions } from 'vuex'
export default {
components:{
Bottom
},
data(){
return{
}
},
computed:{
...mapState([
'logo',
'menu',
'breadcrumbs',
'tags'
])
},
解决了,配合js-cookie: