ソースを参照

bugfix 空对象判断

谢杰标 2 年 前
コミット
e566151dbd
2 ファイル変更7 行追加2 行削除
  1. 6 0
      common/methodTool.js
  2. 1 2
      pages3/polyv/detail.vue

+ 6 - 0
common/methodTool.js

@@ -725,4 +725,10 @@ export default {
       /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
     return reg.test(str);
   },
+  isObject (object) {
+    return object !== null && typeof object === 'object'
+  },
+  isEmptyObject (object) {
+    return this.isObject(object) && Object.keys(object).length < 1
+  }
 };

+ 1 - 2
pages3/polyv/detail.vue

@@ -178,7 +178,7 @@
             v-for="(item, index) in menuList"
             :key="index"
           >
-            <template v-if="sectionItem.userId">
+            <template v-if="!$method.isEmptyObject(sectionItem)">
               <!--模块 -->
               <view v-if="item.type == 1"
                 ><courseModule
@@ -3705,7 +3705,6 @@ export default {
     },
     getGoodsDetail() {
       let self = this;
-      // '/goods/'+ data,
       this.$api.goodsDetail(this.goodsId).then(async (res) => {
         this.goodsData = res.data.data;
         this.option.periodWaitTime && (await this.checkFinishRequiredCourse());