react中遇到的事

前端之家收集整理的这篇文章主要介绍了react中遇到的事前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.路由跳转问题:

        。 可以使用标签跳转,如Link .NavLink等。

        。 如果组件是在Route中的组件,那么该组件的this.props.history.push()可以设置路由,如果组件不在Route中,那么this.props中没有history对象。

        。使用 history模块

import { createHashHistory } from history
const history = createHashHistory()
ReactDOM.render(<Router history={history} routes={routes}></Router>,...)

2.组件上不能加clssName,加clssName无效。

猜你在找的React相关文章