tableDates:[]不在data定义了,直接使用store在computed里,但changeOrder里this.tableDates取了,方法无效
来源:8-3 vuex在项目中的应用(2)

Eumenide
2017-05-17
写回答
2回答
-
是不能了, tableDate现在属于store里的数据,不能直接在组件里改,_orderBy 会更改tableDates,改的只是当前组件的this.tableDates 而不是 store里的tableDates,你改不到 store里的tableDates,所以getters也不会重新去取。
这种情况下,需要store里写一个 changeOrder 的 action,参数一样往里传, 在组件层面调用这个action(或者mutation,因为不需要异步),改变store里的tableDate,getter就会自动获取更新后的数据。
032018-01-22 -
Eumenide
提问者
2017-05-17
现在就是changeOrder这个方法失效了,是不是不能 this.tableDates=_.orderBy(this.tableDates,headItem.key,this.currentOrder)
这样取值了,该怎么取?
00
相似问题