Browse Source

高度取值问题

xiaohaizhao 1 năm trước cách đây
mục cha
commit
42dd1c8c06
1 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 7 3
      components/My_listbox.vue

+ 7 - 3
components/My_listbox.vue

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