1. 子组件内,调用mapActions报错解决方法:
引入 import store from '../../store';
调用actions的方法:
store.dispatch('checkSatId', params).then(res => {
if (!res.data) {
this.errors = '新增卫星ID不能重复!'
} else {
this.moValida();
}
})
这样就可以调到了。
之前那种
import { mapActions, mapState } from "vuex";
...mapActions(["checkSatId"]),
this.checkSatId() 这样调用是报Cannot read property 'dispatch' of undefined这个错的。