滑动到顶部

This commit is contained in:
luyuan 2020-08-13 15:06:49 +08:00
parent 87e5515b98
commit 1a3b39f31e
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3

View File

@ -11,7 +11,7 @@
</view> </view>
<view class="evaluation" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">好评</view> <view class="evaluation" :class="{ 'current' : current == 2 }" @click="switchCurrent(2)">好评</view>
</view> </view>
<scroll-view scroll-y class="goods-container" :style="{ height: scrollHeight }" @scrolltolower="loadMore" :scroll-top="top"> <scroll-view scroll-y class="goods-container" :style="{ height: scrollHeight }" @scrolltolower="loadMore" :scroll-top="scrollTop" @scroll="scroll">
<view v-for="goods in goodsList" :key="goods.goods_id" class="goods-item" @click="toDetailsPage(goods.goods_id)"> <view v-for="goods in goodsList" :key="goods.goods_id" class="goods-item" @click="toDetailsPage(goods.goods_id)">
<image :src="goods.goods_image"></image> <image :src="goods.goods_image"></image>
<view class="right"> <view class="right">
@ -39,7 +39,10 @@ export default {
loadStatus: 'loadmore', loadStatus: 'loadmore',
timer: true, // , timer: true, // ,
value:"", value:"",
top:0 scrollTop: 0,
old: {
scrollTop: 0
}
} }
}, },
watch: { watch: {
@ -65,6 +68,9 @@ export default {
this.ShopSearch() this.ShopSearch()
}, },
methods: { methods: {
scroll: function(e) {
this.old.scrollTop = e.detail.scrollTop; //
},
setNavSearchInput(keyword) { setNavSearchInput(keyword) {
console.log(keyword); console.log(keyword);
// #ifdef APP-PLUS // #ifdef APP-PLUS
@ -133,7 +139,10 @@ export default {
switchCurrent(current) { switchCurrent(current) {
this.page = 1 this.page = 1
if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc; if(current == 1 && this.current == 1) this.priceOrderAsc = !this.priceOrderAsc;
this.top=0 this.scrollTop = this.old.scrollTop
this.$nextTick(function() {
this.scrollTop = 0
});
this.ShopSearch() this.ShopSearch()
this.current = current; this.current = current;
}, },