vuex中unknown mutation type:的解决
页面在使用invoice.js的mutations中方法时需要加上模块名,如图所示。<script>import {mapState,mapMutations} from 'vuex'export default {data() {return {invoiceData: {}}},computed: {...mapState({picker:state=>state.invoi
·
页面在使用invoice.js的mutations中方法时需要加上模块名,如图所示。
<script>
import {mapState,mapMutations} from 'vuex'
export default {
data() {
return {
invoiceData: {}
}
},
computed: {
...mapState({
picker:state=>state.invoice.picker
}),
pickerIndex: {
get() {
return this.$store.state.invoice.pickerIndex;
},
set(val) {
this.$store.state.invoice.pickerIndex = val
this.$store.commit("invoice/formData", {
val: val,
id: 1
});
}
}
}
}
</script>
其他情况需要检查拼写问题或检查invoice.js中namespaced:true是否设置
更多推荐
已为社区贡献1条内容
所有评论(0)