【发布时间】:2017-06-10 15:22:14
【问题描述】:
我有一个 Vuex 商店,我将其注入到我的实例中:
import store from '../store';
const mainNav = new Vue({
el: '#main-nav',
store,
components: { NavComponent }
});
我正在组件中从该商店创建一个计算属性:
computed: {
isWide() {
return this.$store.state.nav.type === 'wide';
}
}
这确实会在组件初始化时为模板创建 this.isWide 属性,但是当更新存储值时,组件不会注册它 - 旧值仍在模板上。
我在这里做错了什么?
【问题讨论】:
标签: javascript vue.js vue-component vuex computed-properties