<button class="btn" @click="removeFromTheCart(index,item.price)">
Remove
</button>
我将两个参数传递给我的操作removeFromTheCart。
removeFromTheCart({ commit }, payload) {
console.log("rooooooohhhhhoooow",payload)
当我在 vuex 存储中控制台记录我的有效负载时,它仅输出索引。 我的第二个参数不在输出中。
如何通过一个操作获取两个参数值?
最佳答案
您可以发送一个对象作为您的负载,如下所示:
<button class="btn" @click="removeFromTheCart({ index, price: item.price })">Remove</button>
并获取您商店中的数据:
removeFromTheCart({ commit }, { index, price }) {
console.log('index', index, 'price', price);
}
关于vuejs2 - VueJS 如何将两个参数传递给 Vuex 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49998296/