页面代码
methods: {
...mapActions(['addList', 'delList']), add (value) { this.addList({title: value})
},
del (item) { this.delList(item)
}
}actions中代码
import * as types from './mutations'export const addList = ({commit}, item) => {
commit(types.ADD_LIST, item)
}
export const delList = ({commit}, item) => {
commit(types.DELETE_LIST, item)
}但是执行会报[vuex] Expects string as the type, but found function.求高手指点一下哪里出错了,非常感谢.
如果把上面代码改为下面的代码就可以执行
methods: { add (value) { this.$store.commit('ADD_LIST', {title: value})
},
del (item) { this.$store.commit('DELETE_LIST', item)
}
}
慕标5832272
冉冉说
随时随地看视频慕课网APP
相关分类