提交 4e716962 编写于 作者: 雪洛's avatar 雪洛

feat: 使用scroll-view替换list-view

上级 15b0376a
<template> <template>
<list-view ref="listView" class="list" :rebound="false" :scroll-with-animation="true" :scroll-y="true" @scrolltolower="loadData()" <scroll-view ref="listView" class="list" :rebound="false" :scroll-with-animation="true" :scroll-y="true" @scrolltolower="loadData()"
@scroll="onScroll"> @scroll="onScroll">
<list-item class="list-item" v-for="(item, index) in dataList" :key="index"> <view class="list-item" v-for="(item, index) in dataList" :key="index">
<text class="title">{{item.title}}</text> <text class="title">{{item.title}}</text>
</list-item> </view>
</list-view> </scroll-view>
</template> </template>
<script> <script>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
methods: { methods: {
loadData() { loadData() {
let index = this.dataList.length let index = this.dataList.length
for (let i = 0; i < 10; i++) { for (let i = 0; i < 20; i++) {
this.dataList.push({ this.dataList.push({
title: index.toString(), title: index.toString(),
} as ListItem) } as ListItem)
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
] as TabItem[], ] as TabItem[],
selectedIndex: -1, selectedIndex: -1,
displayArrow: false, displayArrow: false,
$tabViewHeight: 0 tabViewHeight: 0
} }
}, },
onLoad() { onLoad() {
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
}, },
onReady() { onReady() {
this.setSelectedIndex(0) this.setSelectedIndex(0)
this.$tabViewHeight = (this.$refs["tabview"] as Element).getBoundingClientRect().height this.tabViewHeight = (this.$refs["tabview"] as Element).getBoundingClientRect().height
}, },
onUnload() { onUnload() {
uni.$off('tabchange', this.onTabPageEvent) uni.$off('tabchange', this.onTabPageEvent)
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
} }
}, },
onTabPageEvent(top : number) { onTabPageEvent(top : number) {
this.displayArrow = top > this.$tabViewHeight this.displayArrow = top > this.tabViewHeight
}, },
setSelectedIndex(index : number) { setSelectedIndex(index : number) {
if (this.selectedIndex === index) { if (this.selectedIndex === index) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册