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

routerRedux.push如何传递数组参数? #1127

Closed
yinxuan1128 opened this issue Aug 13, 2017 · 2 comments
Closed

routerRedux.push如何传递数组参数? #1127

yinxuan1128 opened this issue Aug 13, 2017 · 2 comments
Labels

Comments

@yinxuan1128
Copy link

dispatch(routerRedux.push({ pathname: location.pathname, query: { ...value, searchTags:tags, page: 1, pageSize, }, }))
这里searchTags是一个数组,但是上面的写法不能正确获取结果,url上的参数显示是searchTags=XXX,如果把url参数改成searchTags[]=XXX就可以获得正确结果,那么怎么在query里面定义数组参数呢?我试着改成searchTags[]:tags,但是程序报错了

@sorrycc
Copy link
Member

sorrycc commented Aug 13, 2017

看了下源码,是用 query-string 进行转义的,但不清楚是否支持数组。https://github.com/ReactTraining/history/blob/44bc923/modules/useQueries.js#L9-L11

你可以自行用 query-string 转转看。

@yozman
Copy link

yozman commented Dec 6, 2017

@yinxuan1128
可以用

// 跳转
this.props.dispatch(routerRedux.push({
  pathname: '',
  state: { searchTags: [] },
}));
// 获取
this.props.location.state;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants