当前位置:网站首页>微信小程序中,从一个页面跳转到另一个页面后,在返回后发现页面同步滚动了
微信小程序中,从一个页面跳转到另一个页面后,在返回后发现页面同步滚动了
2022-07-05 09:46:00 【huxiaoxiao.】
问题描述:
最近项目中有一个bug,在一个组件中引入了另一个组件,假设这两个组件名称分别为 A 和 B
我在A页面的顶部点击跳转到B页面,在B页面滚动到底部,选取了一个值自动返回A(或者点击顶部返回键返回到A),这时候会发现A也滚动到了最底部。
解决方法:
1.不推荐,推荐用2
通过威信小程序自带的组件 scroll-view,设置固定高度,在通过scroll-view中的 bindscroll方法,在滚动时获取距离顶部的距离,并赋值保存下来。在返回上一层页面的方法中调用 wx.pageScrollTo,其中的 scrollTop就是你记录的那个值,就行了
2.
跟第一个方法类似,但更简单,也是运用 scroll-view,把你整个 A 的可滚动区域包裹起来,注意是可滚动区域,固定高度就发现问题解决了
在这里多提一句,一般正常的返回键是小程序自带的,正常返回也不会有这个问题,仅供参考!
边栏推荐
- Data visualization platform based on template configuration
- Tianlong Babu TLBB series - questions about skill cooling and the number of attack ranges
- On July 2, I invite you to TD Hero online press conference
- 【小技巧】獲取matlab中cdfplot函數的x軸,y軸的數值
- MySQL character type learning notes
- C#函数返回多个值方法
- Six simple cases of QT
- 如何判断线程池已经执行完所有任务了?
- @JsonAdapter注解使用
- [app packaging error] to proceed, either fix the issues identified by lint, or modify your build script as follow
猜你喜欢
Mysql80 service does not start
Cent7 Oracle database installation error
The comparison of every() and some() in JS uses a power storage plan
Kotlin compose and native nesting
[200 opencv routines] 219 Add digital watermark (blind watermark)
一种用于干式脑电图的高密度256通道电极帽
Wechat applet - simple diet recommendation (3)
[system design] index monitoring and alarm system
Application of data modeling based on wide table
ConstraintLayout的流式布局Flow
随机推荐
Getting started with Apache dolphin scheduler (one article is enough)
Wechat applet - simple diet recommendation (3)
【小技巧】獲取matlab中cdfplot函數的x軸,y軸的數值
Cent7 Oracle database installation error
Pagoda panel MySQL cannot be started
Z-blog template installation and use tutorial
(1) Complete the new construction of station in Niagara vykon N4 supervisor 4.8 software
StaticLayout的使用详解
Apache dolphin scheduler system architecture design
硬核,你见过机器人玩“密室逃脱”吗?(附代码)
能源势动:电力行业的碳中和该如何实现?
Cerebral Cortex:有向脑连接识别帕金森病中广泛存在的功能网络异常
Cut off 20% of Imagenet data volume, and the performance of the model will not decline! Meta Stanford et al. Proposed a new method, using knowledge distillation to slim down the data set
最全是一次I2C总结
Application of data modeling based on wide table
TDengine × Intel edge insight software package accelerates the digital transformation of traditional industries
[tips] get the x-axis and y-axis values of cdfplot function in MATLAB
How to correctly evaluate video image quality
基于单片机步进电机控制器设计(正转反转指示灯挡位)
Is it really reliable for AI to make complex decisions for enterprises? Participate in the live broadcast, Dr. Stanford to share his choice | qubit · viewpoint