Vuex使用mutations方法无法将数据给state

img

img

img


使用Vuex调用接口获取数据,数据得到了,但是不知道为什么mutations里面的store.selectDate = data;无法将数据给state的selectData,Vuex文件的 console.log都可以将数据输出,也就是数据得到了,但是其他地方用this.$store.state.selectData无法得到数据,如果给selectDate设置默认值,this.$store.state.selectData可以拿到默认值,表示this.$store.state.selectData没问题,就是无法将获得的数据给state的selectData。不清楚为什么。

就是vue里面的模板不知道这个值变化了,不要把你的this.$store.state.selectData放在computed里面,之后访问comouted里面的值

mutations里面的store.selectDate = [...data]