瀏覽代碼

高度取值问题

xiaohaizhao 1 年之前
父節點
當前提交
42dd1c8c06
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      components/My_listbox.vue

+ 7 - 3
components/My_listbox.vue

@@ -2,7 +2,7 @@
     <view class="container" :style="{ background: boxBackground }">
         <view id="mylisttop" />
         <scroll-view class="scroll-view" scroll-y :refresher-enabled='pullDown' :refresher-triggered='inRefresh'
-            :style="{ height: height || defaultHeight + 'px' }" :triggered='true' @refresherrefresh='pullToRefresh'
+            :style="{ height: (height || defaultHeight) + 'px' }" :triggered='true' @refresherrefresh='pullToRefresh'
             :scroll-into-view="scrollIntoView" :lower-threshold='300' :scroll-with-animation="true"
             @scrolltolower='loadThePage'>
             <view id="header">
@@ -47,7 +47,8 @@ export default {
             default: ""
         },
         defaultHeight: {
-            type: [String, Number]
+            type: [String, Number],
+            default: 0
         }
     },
     data() {
@@ -61,7 +62,9 @@ export default {
         };
     },
     mounted() {
-        if (this.automatic) this.setHeight()
+        if (this.automatic) setTimeout(() => {
+            this.setHeight()
+        }, 100);
     },
     methods: {
         /* 下拉刷新 */
@@ -92,6 +95,7 @@ export default {
                             height = res - num;
                             break;
                     }
+                    console.log("高度", height)
                     if (this.height != height) this.height = height;
                     resolve(height)
                 });