当前位置:网站首页>微信小程序中,从一个页面跳转到另一个页面后,在返回后发现页面同步滚动了
微信小程序中,从一个页面跳转到另一个页面后,在返回后发现页面同步滚动了
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 的可滚动区域包裹起来,注意是可滚动区域,固定高度就发现问题解决了
在这里多提一句,一般正常的返回键是小程序自带的,正常返回也不会有这个问题,仅供参考!
边栏推荐
- 天龙八部TLBB系列 - 关于包裹掉落的物品
- A high density 256 channel electrode cap for dry EEG
- Design and Simulation of fuzzy PID control system for liquid level of double tank (matlab/simulink)
- 字节跳动面试官:一张图片占据的内存大小是如何计算
- Openes version query
- 善用兵者,藏于无形,90 分钟深度讲解最佳推广价值作品
- @JsonAdapter注解使用
- MySQL digital type learning notes
- Small program startup performance optimization practice
- Tianlong Babu TLBB series - questions about skill cooling and the number of attack ranges
猜你喜欢

Single chip microcomputer principle and Interface Technology (esp8266/esp32) machine human draft

卷起來,突破35歲焦慮,動畫演示CPU記錄函數調用過程

90%的人都不懂的泛型,泛型的缺陷和应用场景

Coordinate system of view

程序员如何活成自己喜欢的模样?

Charm of code language

Application of data modeling based on wide table

如何獲取GC(垃圾回收器)的STW(暫停)時間?

Small program startup performance optimization practice

Analysis on the wallet system architecture of Baidu trading platform
随机推荐
Advanced opencv:bgr pixel intensity map
如何获取GC(垃圾回收器)的STW(暂停)时间?
Dedecms website building tutorial
Unity particle special effects series - the poison spray preform is ready, and the unitypackage package can be used directly - next
ArcGIS Pro creating features
宝塔面板MySQL无法启动
@JsonAdapter注解使用
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
驱动制造业产业升级新思路的领域知识网络,什么来头?
View Slide
Android SQLite database encryption
Comment obtenir le temps STW du GC (collecteur d'ordures)?
To bring Euler's innovation to the world, SUSE should be the guide
90%的人都不懂的泛型,泛型的缺陷和应用场景
单片机原理与接口技术(ESP8266/ESP32)机器人类草稿
Generics, generic defects and application scenarios that 90% of people don't understand
Apache DolphinScheduler 入门(一篇就够了)
盗版DALL·E成梗图之王?日产5万张图像,挤爆抱抱脸服务器,OpenAI勒令改名
Swift tableview style (I) system basic
如何写出高质量的代码?