Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

滚动条缓存封装(不是提bug) #3

Closed
jian-qin opened this issue Feb 11, 2020 · 4 comments
Closed

滚动条缓存封装(不是提bug) #3

jian-qin opened this issue Feb 11, 2020 · 4 comments

Comments

@jian-qin
Copy link

只是一个优化建议,并不是提一个bug。

原因:页面缓存并没有保存滚动条位置,对用户体验不友好。

我现在的解决方案:

代码:截图

原理:在页面跳转时存储并设置滚动条位置,将页面中class="_scroll"的滚动条数值存储在this._scroll中;当页面存在多个class="_scroll"时,只会对最后一个生效。

这个是用来配合feb-alive使用的,如果能把滚动条也封装那就更好了;
谢谢作者大佬的feb-alive。

@hangaoke1
Copy link
Collaborator

感谢建议,目前项目里滚动位置一般是通过配置vue-router的scrollBehavior实现的

@jian-qin
Copy link
Author

jian-qin commented Feb 12, 2020

额,好吧。这scrollBehavior只记录页面文档滚动位置,没有记录局部元素的滚动位置,有局限性对我来说没啥用。
我还是用自己的解决方案:截图

@hangaoke1
Copy link
Collaborator

局部情况比较多,比如一个页面可能有多个局部滚动容器,所以这部分主要还是业务实现,不过你这个建议可以考虑插件提供一个公共方法简化业务使用类似业务需求

@hangaoke1
Copy link
Collaborator

局部容器滚动高度建议自行封装scroll-view组件,将滚动高度同步保存至组件的data属性上,可参考uni-app在H5下实现的scroll-view组件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants