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

page cache #43

Open
fengwuxiao opened this issue Nov 2, 2017 · 3 comments
Open

page cache #43

fengwuxiao opened this issue Nov 2, 2017 · 3 comments

Comments

@fengwuxiao
Copy link

请问一下,没有什么办法改变缓存页面的某个state,我对首页设置cache
<Route index component={Home} path= '/home' cache />
从其他页面返回后,我想根据路由传回的参数改变首页某项state的值,其他状态不变,不知道有没有什么好的办法解决

@lanistor
Copy link
Owner

lanistor commented Nov 5, 2017

缓存恢复后的状态,是由渲染时刻的状态(state,location等)决定的。可以在组件里监听地址的变化,做相应的处理,目前监听地址变化的方法尚未开放(方案正在制定中),可以采用浏览器原生API如window.onhashchange来实现。

@lanistor
Copy link
Owner

lanistor commented Mar 4, 2018

Good one: next version 3

@caicai199604
Copy link

@vifird window.onhashchange 无法监听到地址的变化,路由跳转是使用
Control.go('/home', { name: '我是名字' }) ,只有在点击浏览器的返回或者前进的时候触发 window.onhashchange 事件。

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

3 participants