We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在 dva1.x 中,组件的 的监听函数写法如下:
function pageChangeHandler(page) { dispatch(routerRedux.push({ pathname: '/users', query: { page }, })); }
然后在 model 中的监听中可以如下面形式进行获取:
subscriptions: { setup({ dispatch, history }) { return history.listen(({ pathname, query }) => { if (pathname === '/users') { dispatch({ type: 'fetch', payload: query }); } }); }, },
但是在2.x中,history的 location 属性上不再包含 query, 需要 query-string 处理一遍。并且要把参数传到 location 中的 search 字段中,例子如下:
function pageChangeHandle(page) { dispatch( routerRedux.push({ pathname: "/user", search: "?page=" + page }) ); }
model 中的监听如下:
subscriptions: { setup({ dispatch, history }) { return history.listen(({ pathname, search }) => { const query = queryString.parse(history.location.search) if (pathname === "/user") { dispatch({ type: "fetch", payload: query ? query : 1 }); } }); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在 dva1.x 中,组件的 的监听函数写法如下:
然后在 model 中的监听中可以如下面形式进行获取:
但是在2.x中,history的 location 属性上不再包含 query, 需要 query-string 处理一遍。并且要把参数传到 location 中的 search 字段中,例子如下:
model 中的监听如下:
The text was updated successfully, but these errors were encountered: