Comments (4)
上周一直忙于公司业务,这么晚回复实在抱歉。
问题是这样的,vue-page-stack 是基于 vue 的 keep-alive 特性,而 keep-alive 主要是保存上一个组件的实例。van-list 组件实例里并没有有关滚动距离的信息,因此恢复的时候自然没有记录上次滚动距离。
这次我替换成了基于 better-scroll 封装的列表组件,其中 Vue 实例中就已经记录了滚动距离,可在恢复的时候记住上次滚动距离。相关截图如下:
from mobile-web-best-practice.
如果不想使用 better-scroll,也可以把页面的滚动距离记录在 vuex 上(可把页面路由当成 key),当恢复缓存的页面时,可在 activated 周期中获取该页面上次的滚动距离,然后设置当前页面滚动距离。
from mobile-web-best-practice.
好的,谢谢,我两者都会试试的
from mobile-web-best-practice.
@s-kuswin 也可以使用 <router-view>
方式,即在列表页通过 <router-view>
加载详情页,这种方式可以确保俩个页面同时保活,而且也有路由栈,类似原生开发中一个页面覆盖另一个页面的方式。
现在已经切换到这种模式,具体代码可以参考里面的代码。
from mobile-web-best-practice.
Related Issues (11)
- 请问一下,react项目该怎么使用配置您的离线包打包插件呢? HOT 1
- 没有适配iPhoneX系列的底部区域 HOT 1
- npm run build编译 异常 HOT 3
- docker-compose.yml HOT 1
- npm install失败,找不到sentry,请问如何解决? HOT 2
- 点击输入框的时候,ios 页面会被放大 HOT 1
- 意见建议收集区 HOT 18
- Mask 页面 频繁点击触发onTap事件导致<li></li>元素放大 HOT 1
- "out-of-memory crash"报错,会直接把浏览器卡死 HOT 1
- 文章描述错误 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobile-web-best-practice.