소스 검색

列表组件

xiaohaizhao 1 년 전
부모
커밋
014a1e996f
1개의 변경된 파일60개의 추가작업 그리고 0개의 파일을 삭제
  1. 60 0
      components/My_listbox.vue

+ 60 - 0
components/My_listbox.vue

@@ -0,0 +1,60 @@
+<template>
+    <view class="container">
+        <view id="mylisttop" />
+        <scroll-view class="scroll-view" scroll-y :refresher-enabled='pullDown' :refresher-triggered='inRefresh'
+            :style="{ height: height + 'px' }" :triggered='true' @refresherrefresh='pullToRefresh' :lower-threshold='300'
+            @scrolltolower='loadThePage'>
+            <slot />
+        </scroll-view>
+    </view>
+</template>
+
+<script>
+export default {
+    name: 'My_listbox',
+    components: {
+    },
+    props: ["getlist", "pullDown"],
+    data() {
+        return {
+            inRefresh: false, //下拉开启自定义项
+            height: 0
+        };
+    },
+    methods: {
+        /* 下拉刷新 */
+        pullToRefresh() {
+            this.inRefresh = true
+            this.$emit("getlist", true)
+        },
+        /* 刷新完成 */
+        RefreshToComplete() {
+            setTimeout(() => {
+                this.inRefresh = false
+            }, 500)
+        },
+        /* 加载分页 */
+        loadThePage() {
+            this.$emit("getlist", false)
+        },
+        /* 设置组件高度 */
+        setHeight() {
+            this.getHeight("#mylisttop", this).then(height => {
+                if (this.height != height) this.height = height
+            });
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.scroll-view {
+    position: relative;
+}
+
+/* 适配苹果手机底部安全距离 */
+.safety {
+    height: constant(safe-area-inset-bottom);
+    height: env(safe-area-inset-bottom);
+}
+</style>