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

Control.go 跳转新的路由地址A->B,如何携带参数,B页面如何接收参数 #93

Open
remberi opened this issue Oct 8, 2018 · 7 comments

Comments

@remberi
Copy link

remberi commented Oct 8, 2018

最近在移动项目中需要使用缓存上一个页面的状态,但是跳转的时候,需要将A页面的信息发送到B页面,react-keeper是怎么实现的

@lanistor
Copy link
Owner

lanistor commented Oct 9, 2018

有两种方式,一种是跳转B页面的时候,携带state,LinkControl.go都已经有支持实现;另一种,用redux这样的框架保存状态。

@qijizhuimeng
Copy link

Control.history.push({ pathname: "StaffSuggestionDetail" , state: rowData.msgId});
你好,通过这种方式向下一个页面传参,如何接受这个参数呢,一直接受不到.急急急!

1 similar comment
@qijizhuimeng
Copy link

Control.history.push({ pathname: "StaffSuggestionDetail" , state: rowData.msgId});
你好,通过这种方式向下一个页面传参,如何接受这个参数呢,一直接受不到.急急急!

@lanistor
Copy link
Owner

@qijizhuimeng 目前可以使用Control.state读取,但是前提是已经跳转到下一个页面了(可以使用Control.history.go(1)跳转到下一个页面)。不过这样做的目的是什么?为什么不用Control.go(path, state)?

@qijizhuimeng
Copy link

是的,谢谢已经能够获取到state.

@qijizhuimeng
Copy link

再请教一下,通过Control.go(path, state)能够传递回调方法吗?如何做

@lanistor
Copy link
Owner

lanistor commented Jan 2, 2019

@qijizhuimeng 路由跳转的回调方法目前无法提供,因为目前浏览器没有开放这样的API,可以自行监听history变化来实现类似功能:

import Control from 'react-keeper';
Control.history && Control.history.listen(function(location, action){

});

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