From 517a6c839179522c3fa39136dd39fdbeee45c49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E8=84=8F=E7=8B=BC?= <786316265@qq.com> Date: Fri, 22 Aug 2025 16:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=95=86=E5=93=81=E4=B8=8D=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E7=9A=84bug=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ProductDetail.vue | 58 ++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/views/ProductDetail.vue b/src/views/ProductDetail.vue index 928733c..6bd01fb 100644 --- a/src/views/ProductDetail.vue +++ b/src/views/ProductDetail.vue @@ -42,6 +42,9 @@ +
+ +
@@ -236,6 +239,8 @@ import { } from '@element-plus/icons-vue' import api from '@/utils/api' +import { watch } from 'vue' + const route = useRoute() const router = useRouter() const userStore = useUserStore() @@ -320,7 +325,7 @@ const buyNow = async () => { } const goToProduct = (productId) => { - router.push(`/product/${productId}`) + router.replace(`/product/${productId}`) } const previewImage = (image) => { @@ -342,15 +347,26 @@ const getUserPoints = async () => { // 生命周期 onMounted(() => { - getProductDetail() + //getProductDetail() getUserPoints() }) + +watch( + () => route.params.id, + (newId) => { + if (newId) { + getProductDetail() + quantity.value = 1 // 重置数量 + } + }, + { immediate: true } +)