Closed mokai closed 8 years ago
使用vuex2,因为把数据源的回调也放在store.js中,在回调中修改state的代码
Vue.set(store.state.history.monthWeights, 1, 10)
在View上边获取
computed: { weekWeights: function(){ return this.$store.state.history.weekWeights } }
然后把weekWeights传到子组件上中,在子组件中watch
watch: { 'data': { handler: function (newData, oldData) { console.log('month-watch:' + newData) }, deep: true } }
为什么不用 getters? http://vuex.vuejs.org/en/getters.html
monthWeights?还是 weekWeights?
Vue.set 的用法似乎错了 http://vuejs.org/api/#Vue-set
@crossjs 解决了,把原先的数组copy一份,设置新值再覆盖原先的数组就好了,谢谢~
使用vuex2,因为把数据源的回调也放在store.js中,在回调中修改state的代码
在View上边获取
然后把weekWeights传到子组件上中,在子组件中watch