diff --git a/src/components/inputBox.vue b/src/components/inputBox.vue index bbb1793..3b33b6b 100644 --- a/src/components/inputBox.vue +++ b/src/components/inputBox.vue @@ -98,6 +98,11 @@ // 提交数据 emit('submit', {title: data.title, price: data.price, num: (data.num == -1 ? 1 : data.num), priceTxt: data.price.toFixed(2)}, props.index); + // 直接清空 + good.value.title = ''; + good.value.price = 0; + good.value.num = -1, + good.value.priceTxt = ''; } diff --git a/src/store/cart.ts b/src/store/cart.ts index 1cdbcd1..36ad5bf 100644 --- a/src/store/cart.ts +++ b/src/store/cart.ts @@ -73,7 +73,7 @@ export const useCartStore = defineStore('cart', () => { } // 如果存在,则直接加数量,前面加判定防止出现意外值 - if (ind >= 0 && state.datalist[ind]) state.datalist[ind].num += data.num; + if (ind >= 0 && state.datalist[ind]) state.datalist[ind].num += data.num; } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 17ce241..286e132 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -34,7 +34,7 @@ - +
@@ -54,7 +54,6 @@ import { vuepop, vuemsg } from 'vue3-popup'; import 'vue3-popup/lib/style.css'; -import { watch } from 'vue'; // 加载store const cartStore = useCartStore(); @@ -144,9 +143,6 @@ import { watch } from 'vue'; index === '' ? cartStore.add(good) : cartStore.update(good, index); - // 重置数据 - goodReset(); - // 关闭弹窗 actBox(0); @@ -181,10 +177,6 @@ import { watch } from 'vue'; } - watch(index, (newX) => { - console.log(newX); - }, {deep: true}) -