项目从vue.js 1.0 升级到 2.0 后,关于 vuex 的部分一直获取不到,下面是我的代码
报错的信息
Property or method "menus" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
state.js
const state = {
menu: menu
}
const mutations = {}
export default new Vuex.Store({
state,
mutations
})
getters.js
export function menus (state) {
return state.menu
}
menu.vue 组件 代码
import { menus } from '../vuex/getters'
export default {
vuex: {
getters: {
menus
}
},
components: {
},
data: function () {
return {
index: ''
}
},
mounted: function () {
}
}
HTML部分
<li v-for="item in menus">
<router-link to="item.url">
</router-link>
</li>
http://cn.vuejs.org/v2/guide/...