I'm using Nuxt and nuxt-vuex-localstorage When i change a item from v-for and it element is inside store i get an error...
<v-btn
@click="addCurrentProduct( subItem)"
v-if="!subItem.carrito"
color="green"
dark
>Agregar</v-btn
>
<v-row v-if="subItem.carrito">
<v-btn @click="subItem.cantidadCarrito--,removeProduct(subItem)" color="green" icon dark>
<v-icon>mdi-minus-circle-outline</v-icon></v-btn
>
<span>{{
subItem.cantidadCarrito
}}</span>
<v-btn @click="subItem.cantidadCarrito++,addProduct(subItem)" color="green" icon dark>
<v-icon>mdi-plus-circle-outline</v-icon></v-btn
>
</v-row>
methods: {
addCurrentProduct( product) {
product.cantidadCarrito++;
product.carrito = true;
console.log("error")
let temp=product
this.$store.commit("localStorage/Sum_Cantidad");
this.$store.commit("localStorage/ADD_PRODUCT", temp);
},
addProduct(producto) {
var temp = this.buscar(producto);
producto.carrito = true;
this.$store.commit("localStorage/ReNew_PRODUCTO", {
index: temp,
producto: producto
});
this.$store.commit("localStorage/Sum_Cantidad");
}
I have error in subItem.cantidadCarrito++, i think that they are connected with Vuex store (Nuxt) and when i change it element, the element is inside of vuex also change and i get it error
我解决了这个问题,从localstorage 在vuex store 内部更改它,当我第一次放置一个项目时,这个元素会自动与localstorage 连接,我无法从本地外部进行任何更改。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.