Giter Club home page Giter Club logo

feb-alive's People

Contributors

dante-dan avatar hangaoke1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

feb-alive's Issues

带参数的路由返回后页面变空白

路由地址是:/community/abur/parentId/409474825232387/type/4
路由配置是:{path: '/community/abur/parentId/:parentId?/type/:type?', name: 'communityAbur', component: communityAbur}

返回调用的是Vue.router.back(), 返回后页面就变成空白的了。
这个页面是公用的,就像省市区一样,点击列表一级一级往下进入。不清楚是不是这个原因。

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

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

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

我现在的解决方案:

代码:截图

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

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

feb-alive 的子路由保活

当父路由是动态路由时,父子路由的保活好像有些问题。

父路由是动态路由时的保活

如上示例中所看到的:

  1. 当进入 /b/{random} 之后,再切换子路由,只会触发子路由的改变,而父路由不会再重新 mounted
  2. 当进入 /b/{random}/sub 的子路由之后,再进入父路由 /b/{random} , 再使用浏览器的返回,返回到 /b/{random}/sub 此时父路由重新 mounted

对于场景 2,预期应该是能复用上次路由的结果。


大概 Debug 了一下,父路由通过 Key 复用 大概和这一行有关系。

我理解因为是动态路由,所以通过 key 复用,是会在 patch 阶段被重新挂载的。

在 `ensureURL` 中使用 `recoverMeta` 会出现的问题

在源码 ensureURL 中会会执行以下操作:

Vue.location.recoverMeta(from, to)

目的是使用缓存的 meta 信息。

然而 ensureURL 的执行周期和 beforeEach 并不是完全对等的,在 popState 的时候,会执行 TransitionTo . 从而执行 ensureURL


由此引发的问题,当我想要对特定组件支持手势返回。一般思路如下:

  1. 将当前路径推入路由,pushState
  2. 监听 popState,并绑定关闭组件的事件
  3. 等待手势返回。

此时返回, router.beforeEach 并没有执行,因为没有发生路由切换。但是 popState -> transitionTo -> ensureURL , 而 ensureURL 中的 febRecord 来源其实是 beforeEach,这就导致了两个路由栈的不统一。

所以可以考虑将 ensureURL 所执行的内容改到 afterEach 吗?

有一个问题想要请教

recoverMeta (from, to) {

  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> 否则有可能导致子路由渲染的不是最新的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.