react--编程式导航、antd的使用

发布日期:2023-07-17 阅读(0) 评论(0) 赞(0)
编程式 1. 借助路由对象中的history 获取: this.props.history.push(/xx/xx) | this.props.history.replace(/xx/xx) 2. 传递sreach参数 this.props.history.push(/xx/xx?xxx100&xx111) 3. 传state参数 this.props.history.push(/xx,{id:1,title:…

编程式

1. 借助路由对象中的history

获取: this.props.history.push('/xx/xx')    |    this.props.history.replace('/xx/xx')

2. 传递sreach参数

this.props.history.push('/xx/xx?xxx=100&xx=111') 

3. 传state参数

this.props.history.push('/xx',{id:1,title:xxx})

控制前进和后退this.porps.history中: goForward()  goBack()   go(1)  go(-1)

withRouter的使用

引入: import {withRouter} from 'react-router-dom'

即可以在一般组件中 的props中收到路由组价特有的api: history、match、location

暴露出去: export default withRouter(Header)

hashRouter 和  BrowserRouter 的区别:

hashRouter 刷新会导致state 丢失,因为根本没有history

 一些ui组件库:

1. material-ui  国外

http://www.material-ui.com/#/

github: 

https://github.com/callemall/material-ui

2. ant-design 国内蚂蚁金服

https://ant.design/index-cn

github:

https://github.com/ant-design/ant-design/

(96) 自定义主题

相关文章
    最新文章
    热门标签