我正在尝试将操作作为组件中的方法进行访问,但出现
错误this.delete_notifaction不是函数
notifaction.js
export const actions = {
add_notifaction({ commit }, notifaction) {
commit("ADD_NOTIFACTION", notifaction);
},
delete_notifaction({ commit }, notificationToRemove) {
commit('DELETE_NOTIFACTION', notificationToRemove)
}
};
store / index.js
modules : {
notifaction
},
Component.vue
methods: mapActions('notifaction',["delete_notifaction"]),
mounted() {
this.delete_notifaction(this.notification);
}
有帮助吗?
答案 0 :(得分:0)
尝试一下
methods: {
...mapActions(['delete_notifaction']),
}
请参阅此处以了解传播语法 https://stackoverflow.com/a/48137766/10118668