Explorar el Código

修复线上切换时的bug

nahida hace 1 año
padre
commit
3e3aac8856
Se han modificado 1 ficheros con 7 adiciones y 7 borrados
  1. 7 7
      src/views/ProductPage/index.vue

+ 7 - 7
src/views/ProductPage/index.vue

@@ -11,7 +11,7 @@
           <el-sub-menu :index="'1' + ''">
             <template #title>硬件产品</template>
             <el-menu-item v-for="(subItem, subIndex) in productList[0]" :key="subIndex" :index="subItem.id"
-              @click="menuItemClick([subItem], 2)" v-show="subItem.productType.length == 3">
+              @click="menuItemClick([subItem], 2)" v-show="subItem?.productType.length == 3">
               {{ subItem?.title }}
             </el-menu-item>
           </el-sub-menu>
@@ -35,7 +35,7 @@
       <div class="flex-1 flex pl-50 justify-start flex-wrap" v-show="RJDis === 2">
         <div v-for="(item, index) in productShow" :key="index"
           class="flex flex-col items-center w-382 h-342 bg-#F6FAFF mb-20 mr-10"
-          v-show="item.productType.length != 3 && currentIndex == item.productType">
+          v-show="item?.productType.length != 3 && currentIndex == item?.productType">
           <img :src="$URL + item?.pathFiles[0]?.filePath" class="h-220 mt-30" loading="lazy" />
           <p class="color-#1D324D my-12">{{ item?.title }}</p>
           <div class="w-94 h-34 bg-#1962EC mb-18 text-center color-#fff leading-34 cursor-pointer"
@@ -50,7 +50,7 @@
     <div class="lg:hidden">
       <subTitle :title="route?.query?.name ? route?.query?.name : '硬件产品'"></subTitle>
       <div v-for="(item, index) in route.query.name === '软件产品' ? productList[1] : productList[0]" :key="index"
-        class="flex flex-col items-center h-342 bg-#F6FAFF mb-20" v-show="item.productType.length != 3">
+        class="flex flex-col items-center h-342 bg-#F6FAFF mb-20" v-show="item?.productType.length != 3">
         <img :src="$URL + item?.pathFiles[0]?.filePath" class="h-220 mt-30" loading="lazy" />
         <p class="color-#1D324D my-12">{{ item?.title }}</p>
         <div class="w-94 h-34 bg-#1962EC mb-18 text-center color-#fff leading-34 cursor-pointer"
@@ -135,16 +135,16 @@ const menuItemClick = (e: any, index: any) => {
   RJDis = index;
   console.log(RJDis)
   //如果是软件产品则任何一项productType为0
-  if (e[0].productType == 'null' || e[0].productType == null) {
+  if (e[0]?.productType == 'null' || e[0]?.productType == null) {
     currentIndex.value = 'null'
     return
   }
-  currentIndex.value = e[0].productType.split('-')[1]
+  currentIndex.value = e[0]?.productType.split('-')[1]
   // productSubItem.value = e
 }
 const defaultActive = computed(() => {
   return productList.value[0].filter((item: any) => {
-    return item.productType.length == 1
+    return item?.productType.length == 1
   })[0]
 })
 
@@ -153,7 +153,7 @@ const productShow = computed(() => {
     return productList.value[1];
   }
   return productList.value[0].filter((item: any) => {
-    return item.productType.length == 1
+    return item?.productType.length == 1
   })
 })
 const currentIndex = ref<string>('null');