<template>
<!-- Page Sidebar -->
<div class="page-sidebar" id="sidebar">
<!-- Page Sidebar Header-->
<div class="sidebar-header-wrapper">
<input type="text" class="searchinput"/>
<i class="searchicon fa fa-search"></i>
<div class="searchhelper">搜索菜单</div>
</div>
<!-- /Page Sidebar Header -->
<!-- Sidebar Menu -->
<ul class="nav sidebar-menu">
<li><a @click="setPageHeaderText('ddd')">sdfds</a></li>
<router-link tag="li" v-for="menu in menus" :to="{ path: menu.text }">
<a v-bind:class="{ 'menu-dropdown':menu.children }" @click="setPageHeaderText(menu.ext.display_name)">
<i class="menu-icon " v-bind:class=" menu.ext.icon "></i>
<span class="menu-text"> { menu.ext.display_name } </span>
<i class="menu-expand" v-if="menu.children"></i>
</a>
<ul class="submenu" v-if="menu.children">
<router-link tag="li" v-for="submenu in menu.children" v-bind:class="'second'"
:to="{ path: submenu.ext.name }"
active-class="active">
<a @click="setPageHeaderText(submenu.ext.display_name)">
<span class="menu-text">{ submenu.ext.display_name }</span>
</a>
</router-link>
</ul>
</router-link>
</ul>
<!-- /Sidebar Menu -->
</div>
<!-- /Page Sidebar -->
</template>
<style scoped>
</style>
<script>
export default{
name:'page-sidebar',
computed:{
menus(){
return this.$store.state.menus
}
},
methods: {
setPageHeaderText(text){
console.log(text)
//动态设置page-header
this.$store.dispatch('setPageHeaderText',text)
}
}
}
</script>
如题vue2.0 在router-link 上面 的<li>sdfds</li> 这句可以执行 但下面ajax请求来的数据遍历的菜单上的事件不执行