wefront / feb-alive Goto Github PK
View Code? Open in Web Editor NEWA Vue page cache plugin
License: MIT License
A Vue page cache plugin
License: MIT License
路由地址是:/community/abur/parentId/409474825232387/type/4
路由配置是:{path: '/community/abur/parentId/:parentId?/type/:type?', name: 'communityAbur', component: communityAbur}
返回调用的是Vue.router.back(), 返回后页面就变成空白的了。
这个页面是公用的,就像省市区一样,点击列表一级一级往下进入。不清楚是不是这个原因。
虽然功能没问题,但是多次replace跳转之后,会缓存一堆重复的页面实例,造成内存资源浪费;希望作者大佬修复一下这个问题。
截图
只是一个优化建议,并不是提一个bug。
原因:页面缓存并没有保存滚动条位置,对用户体验不友好。
我现在的解决方案:
代码:截图
原理:在页面跳转时存储并设置滚动条位置,将页面中class="_scroll"的滚动条数值存储在this._scroll中;当页面存在多个class="_scroll"时,只会对最后一个生效。
这个是用来配合feb-alive使用的,如果能把滚动条也封装那就更好了;
谢谢作者大佬的feb-alive。
Line 9 in 3fb1dcc
代码中直接将 debug 信息暴露在 window 上,首先这不安全。
其次,由于 cache_debug[depth] = this.cache
,cache_debug
持有了组件内部的 cache
变量,当 feb-alive
正常的创建和销毁时,无法正常释放掉变量 cache
,存在内存泄漏的隐患。
feb-alive/src/components/feb-alive.js
Line 38 in e6b10f7
这个是咋实现的吖,我没有看到 foreceUpdate
的代码,而且这样可能会有问题。
这种每次路由变化都 render 的实现方式,会导致嵌套路由时,不该 render 的 feb-alive 重新缓存了新的 vnode
Iframe is inserted in vue, but the iframe page will be reloaded when switching between different pages. Can this be added to the firame framework?
当父路由是动态路由时,父子路由的保活好像有些问题。
如上示例中所看到的:
/b/{random}
之后,再切换子路由,只会触发子路由的改变,而父路由不会再重新 mounted
。/b/{random}/sub
的子路由之后,再进入父路由 /b/{random}
, 再使用浏览器的返回,返回到 /b/{random}/sub
此时父路由重新 mounted
。对于场景 2,预期应该是能复用上次路由的结果。
大概 Debug
了一下,父路由通过 Key 复用 大概和这一行有关系。
我理解因为是动态路由,所以通过 key
复用,是会在 patch
阶段被重新挂载的。
在源码 ensureURL
中会会执行以下操作:
Line 52 in cd4a9a5
然而 ensureURL
的执行周期和 beforeEach
并不是完全对等的,在 popState
的时候,会执行 TransitionTo . 从而执行 ensureURL 。
由此引发的问题,当我想要对特定组件支持手势返回。一般思路如下:
此时返回, router.beforeEach
并没有执行,因为没有发生路由切换。但是 popState -> transitionTo -> ensureURL
, 而 ensureURL
中的 febRecord
来源其实是 beforeEach
,这就导致了两个路由栈的不统一。
所以可以考虑将 ensureURL
所执行的内容改到 afterEach
吗?
Line 148 in 2fd3cd1
Vue.location.recoverMeta(from, to)
看到 recoverMeta 会修改路由的 meta 信息,但是我理解 meta 和 route 应该是绑定的,并且不应该被修改。为什么在命中某些判断之后去修改 meta 呢?
当多次 replace 同一个路径,是不是会存在潜在的 meta 信息错乱的问题。
路由 /a/b/c --> /a/m/n
根路由
<feb-alive>
<router-view />
</feb-alive>
二级路由
<feb-alive>
<router-view />
</feb-alive>
如果/a/b/c路由不需要缓存 全部设置禁止缓存
由于渲染父组件的时候不会走到
https://github.com/wefront/feb-alive/blob/master/src/components/feb-alive.js#L101
那么如果b下边的子路由不包裹<feb-alive>
不走render这个判断 可能复用了已缓存的父路由中的c组件导致渲染没有刷新
所以请问是不是全局路由都需要包裹<feb-alive>
否则有可能导致子路由渲染的不是最新的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.