直接上码
说明:注释部分为使用this.$store.dispatch(‘medo’,mdo);形式
没有注释部分为使用…mapActions形式
<template>
<div>
<!--<button @click="medo()">点我</button>-->
<button @click="clickme()">点我</button>
</div>
</template>
<script>
import {mapActions} from 'vuex'
export default {
methods:{
// medo(){
// const mdo="我来了";
// this.$store.dispatch('medo',mdo);
// }
clickme(){
this.medo("我来了");
},
...mapActions(['medo'])
}
}
</script>
<style>
</style>
这样在action中就可以得到自定义参数"我来了"啦