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

几点疑惑 #111

Open
ldwstyle opened this issue Jun 13, 2019 · 12 comments
Open

几点疑惑 #111

ldwstyle opened this issue Jun 13, 2019 · 12 comments

Comments

@ldwstyle
Copy link

ldwstyle commented Jun 13, 2019

1.react-keeper有没有类似react-router withRouter的组件,让我能够在页面中获取路由信息。
2.react-keeper的Route匹配规则有没有类似react-router

<Switch location={location}></Switch>

的匹配规则,主要解决页面跳转动画问题。举例:用react-transition-group做动画,从首页进入列表页面,首页移除,列表页渲染,但是react-transition-group会把首页保留一段时间(做动画使用),但是Route会强行把首页替换成列表页(由于浏览器地址变了),结果是页面上出现2个列表页,这样我根本无法做动画。
3.leaveFilter。举例说明:

<Route  component={Index} leaveFilter={this.leaveFilter}  path="/" />     
<Route  component={List} leaveFilter={this.leaveFilter} path="/project/:projectId>" />    
<Route  component={Task} leaveFilter={this.leaveFilter} path="/project/:projectId/task/:taskId>" />   

从Index页面进入List页面,会触发每个Route的leaveFilter,我认为应该只触发Index-Route的leaveFilter,因为当前就是Index离开了。

@jingjing17890
Copy link

您好,请问你的列表页,能缓存住滚动位置吗?

@ldwstyle
Copy link
Author

@jingjing17890
您的这个提问跟我说的几个疑惑好像没有什么关系,如果您要是作缓存的话,react-keeper有作缓存的api,是可以缓存住滚动条的位置的,他的缓存原理就是把要缓存的页面加了display:none

@jingjing17890
Copy link

jingjing17890 commented Jun 18, 2019 via email

@jingjing17890
Copy link

jingjing17890 commented Jun 18, 2019 via email

@lanistor
Copy link
Owner

lanistor commented Jun 18, 2019 via email

@jingjing17890
Copy link

jingjing17890 commented Jun 18, 2019 via email

@lanistor
Copy link
Owner

@ldwstyle 可以尝试使用下context.history。

@jingjing17890
Copy link

jingjing17890 commented Jun 18, 2019 via email

@jingjing17890
Copy link

jingjing17890 commented Jun 18, 2019 via email

@ldwstyle
Copy link
Author

@vifird
请问context.history如何使用,谢谢!

@lvSally
Copy link

lvSally commented Dec 26, 2019

第一个问题我也遇到了,我参考的是这个如何监听URL的变化
具体实现

function addHistoryEvent (type) {
  var origin = history[type]
  return function() {
    var rv = origin.apply(this, arguments)
    var e = new Event(type)
    e.arguments = arguments
    window.dispatchEvent(e)
    return rv
  }
}

history.pushState = addHistoryEvent('pushState')
history.replaceState = addHistoryEvent('replaceState')

window.addEventListener('replaceState', this.getUrlKeyWrap)
window.addEventListener('pushState', this.getUrlKeyWrap)
window.addEventListener('popstate', this.getUrlKeyWrap)

@mamababa
Copy link

mamababa commented Sep 2, 2020

@vifird
请问context.history如何使用,谢谢!
作者有解决这个滚动的问题吗,我的也缓存不住滚动条

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

5 participants