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

切换 tab 的时候如何保存 tab 高度? #15

Closed
werbhelius opened this issue Jun 1, 2017 · 4 comments
Closed

切换 tab 的时候如何保存 tab 高度? #15

werbhelius opened this issue Jun 1, 2017 · 4 comments

Comments

@werbhelius
Copy link

werbhelius commented Jun 1, 2017

现在切换 tab 的时候,如果发生滑动,其他的页面也会随之滑动,如何解决这个问题?

@jeneser
Copy link
Owner

jeneser commented Jun 1, 2017

谢谢您提交issue给我!
这个问题我也注意到了,自定义路由切换时页面如何滚动?正在解决中...
其根源在于:两个路由出口对应的视图共用同一个根路由出口,每次发生滑动,将会相互影响。

有几个解决思路:

  1. 为每一个视图添加加载状态,每次渲染页面之前,先展示加载动画,由于页面高度不足,滚动高度消失,页面之间便不会影响了,但是每次访问都会回到顶部,体验不佳。
  2. 通过导航钩子精确控制:记录页面位置,在每次路由变更时更新位置信息。
  3. 使用vue-router的scrollBehavior。scrollBehavior仅在HTML5 history 模式下可用,本项目使用的是hash模式。
    参考:滚动行为

这边会优先使用第二个思路,正在解决中...
再次感谢!~

@werbhelius
Copy link
Author

好!期待你解决!

@jeneser
Copy link
Owner

jeneser commented Jun 3, 2017

已解决!
我写了一个通用的插件来解决这个问题,使得滚动行为在HTML5 history和hash模式下保持一致。
目前插件正在更新中,不过,我已经将它用在了项目中,你可以查看live demo来体验。欢迎您为此插件提出宝贵意见。有关具体实现,请移步插件仓库:vue-scroll-behavior

我将关闭本issue,Thanks!

@jeneser jeneser closed this as completed Jun 3, 2017
@werbhelius
Copy link
Author

Good!

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