mapGetters 是在computed属性中使用的可以写对象或者数组形式如下:
1.示例在对象中键是在插值语法中使用的名字{{ons}}他的值是在store文件中的Getters属性内对应的获取值的函数
2.示例在使用数组“onx”是对象方式的简写而已
computed:{
// ...mapGetters({ ons:"onx"})
...mapGetters(["onx"])
}
mapActions 是methods 属性中的辅助函数也可以使用对象和数组的方式:
methods: {
//y是点击事件的名字"y"是store 里面acthins中的函数名称
//...mapActions({y:"y"})
//下面是简写方式
...mapActions(["y"])
},
注意:需要传递参数的话是不能在辅助函数中直接使用而是在事件后面直接传递比如: @click=y(content)
actions: {
y({commit},content){commit("Y",content)}
},
mutations: {
Y(state,content){
state.y = "我是谁????"+content
}
},