dispatch(routerRedux.push({
pathname: location.pathname,
query: {
...value,
searchTags:tags,
page: 1,
pageSize,
},
}))
这里searchTags是一个数组,但是上面的写法不能正确获取结果,url上的参数显示是searchTags=XXX,如果把url参数改成searchTags[]=XXX就可以获得正确结果,那么怎么在query里面定义数组参数呢?我试着改成searchTags[]:tags,但是程序报错了
看了下源码,是用 query-string 进行转义的,但不清楚是否支持数组。https://github.com/ReactTraining/history/blob/44bc923/modules/useQueries.js#L9-L11
你可以自行用 query-string 转转看。
@yinxuan1128
可以用
// 跳转
this.props.dispatch(routerRedux.push({
pathname: '',
state: { searchTags: [] },
}));
// 获取
this.props.location.state;
Most helpful comment
@yinxuan1128
可以用