提交 49abb93a 编写于 作者: 雪洛's avatar 雪洛

feat: 自定义tabBar模板适配微信小程序

上级 11c7816c
<template> <template>
<scroll-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" :scroll-top="newScrollTop" @scrolltolower="loadData()"
@scroll="onScroll"> @scroll="onScroll">
<view 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> -->
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
export default { export default {
data() { data() {
return { return {
dataList: [] as ListItem[] dataList: [] as ListItem[],
oldScrollTop: 0,
newScrollTop: 0
} }
}, },
created() { created() {
...@@ -38,10 +40,15 @@ ...@@ -38,10 +40,15 @@
}, },
onScroll(e : ScrollEvent) { onScroll(e : ScrollEvent) {
uni.$emit('tabchange', e.detail.scrollTop) uni.$emit('tabchange', e.detail.scrollTop)
this.oldScrollTop = e.detail.scrollTop
}, },
scrollTop(top : number) { scrollTop(top : number) {
(this.$refs["listView"] as UniElement).scrollTop = top // (this.$refs["listView"] as UniElement).scrollTop = top
// console.log("tab1 to top"); // console.log("tab1 to top");
this.newScrollTop = this.oldScrollTop
this.$nextTick(() => {
this.newScrollTop = top
})
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册