Leanote's Blog
I love Leanote!
Toggle navigation
Leanote's Blog
Home
Chrome
Git
Linux
Windows
Others
工具大全
VsCode
Expo
Html
JavaScript
Npm
Node
Mock
React-Native
React
TypeScript
小程序
插件
正则
Dva
Ant-Design-React
Umi
Vue
Vux
Ant-Design-Vue
Http
Java
flutter
开发小工具
About Me
Archives
Tags
dva下的router(路由跳转传参)
2019-11-14 07:46:47
120
0
0
admin
### 1. 切换 history 为 browserHistory(适用于routes里的页面里使用) import { browserHistory } from 'dva/router'; const app = dva({ history: browserHistory, }); #### 传参方式1 browserHistory.push(pathname: '/routerName/123') 取参 this.props.params.value #### 传参方式2 browserHistory.push({pathname: "/page", state: {key: value}}) 取参 this.props.location.state.key ### 2. routerRedux import { routerRedux } from 'dva/router'; // 在 Effects 里 yield put(routerRedux.push('/logout')); // 不在 Effects 里 dispatch(routerRedux.push('/logout')); // 传参 routerRedux.push({ pathname: '/logout', query: { page: 2, }, }); // 取参 this.props.location.query.page ### 3. Link import { Link } from 'dva/router'; // 传参 ## 路由传参key(state, query, search, param) //使用search import qs from 'query-string'; routerRedux.push({ pathname: '/', search: qs.stringify({ abc: '123', }) })
Pre:
dva基础(书签大全)
Next:
export注意点
0
likes
120
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.