hookehuyr

fix 搜索时报错问题处理

1 <!-- 1 <!--
2 * @Date: 2024-09-27 16:53:09 2 * @Date: 2024-09-27 16:53:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-28 17:58:59 4 + * @LastEditTime: 2024-10-29 14:03:32
5 * @FilePath: /hager/src/views/product/index.vue 5 * @FilePath: /hager/src/views/product/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
33 <div class="product-list"> 33 <div class="product-list">
34 <div class="product-item" v-for="(item, index) in product_list" :key="index"> 34 <div class="product-item" v-for="(item, index) in product_list" :key="index">
35 <div class="product-item-img"> 35 <div class="product-item-img">
36 - <img style="width: 100%; height: auto;" :src="item.product_status === 'publish' ? item.cover : no_product_img"> 36 + <img style="width: 100%; height: auto;" :src="item.cover">
37 </div> 37 </div>
38 <p @click="goToDetail(item)" class="product-item-title">{{ item.product_name }}</p> 38 <p @click="goToDetail(item)" class="product-item-title">{{ item.product_name }}</p>
39 </div> 39 </div>
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
44 <div v-else class="product-list"> 44 <div v-else class="product-list">
45 <div class="product-item xs" v-for="(item, index) in product_list" :key="index"> 45 <div class="product-item xs" v-for="(item, index) in product_list" :key="index">
46 <div @click="goToDetail(item)" class="product-item-img xs"> 46 <div @click="goToDetail(item)" class="product-item-img xs">
47 - <img style="width: 35vw; height: auto;" :src="item.product_status === 'publish' ? item.cover : no_product_img"> 47 + <img style="width: 35vw; height: auto;" :src="item.cover">
48 </div> 48 </div>
49 <p @click="goToDetail(item)" class="product-item-title">{{ item.product_name }}</p> 49 <p @click="goToDetail(item)" class="product-item-title">{{ item.product_name }}</p>
50 </div> 50 </div>
...@@ -143,13 +143,14 @@ export default { ...@@ -143,13 +143,14 @@ export default {
143 const { code, data } = await getProductSearchAPI({ keyword: this.keyword }); 143 const { code, data } = await getProductSearchAPI({ keyword: this.keyword });
144 if (code) { 144 if (code) {
145 this.product_list = data; 145 this.product_list = data;
146 - this.$router.push({ 146 + //
147 - path: '/product/index', 147 + this.$router.replace({
148 + path: this.$route.path,
148 query: { 149 query: {
149 - id: this.$route.query.id, 150 + ...this.$route.query,
150 keyword: this.keyword 151 keyword: this.keyword
151 } 152 }
152 - }) 153 + });
153 } 154 }
154 } else { // 清空搜索值,还原 155 } else { // 清空搜索值,还原
155 this.$router.push({ 156 this.$router.push({
......