我想把数据通过actions存到state中
//组件中的方法
methods: {
selectPlayList(item) {
this.playList = item
this.$router.push({
path: `/playList/${item.id}`
})
this.SetplayList(this.playList)
},
...mapActions([
'SetplayList'
])
// ...mapMutations({
// SetplayList: 'SetplayList'
// })
}
//actions.js
export const SetplayList = ({commit}, playList) => commit('SetplayList')
//mutations.js
export const SetplayList = (state, payload) => {
state.playList = payload
}
logger中payload是unfinded,但是用mapmutation就能正确传数据,这是为什么呢?