【发布时间】:2019-07-24 14:44:01
【问题描述】:
当我收到错误时,可以使用 React Router 在 React 中为 gh-pages 实现 https://name.github.io/project 上的相对路径。
我使用import {withRouter} from 'react-router-dom'; 和export default withRouter(componentName); 将路由道具从路由器转发到目标组件,然后我收到了它们。
我试过这样实现链接:
<li><Link to={{pathname: this.props.match.url + '/new-post'}}>New Post</Link></li>
并使用this.props.match.url这种方式获取当前路径,但我收到错误。
大家有什么建议吗?
【问题讨论】:
-
你有匹配的
吗? -
@mhatch 匹配的
是什么意思?我是否在 中实现了相同的:路径名:this.props.match.url + '/new-post'?
标签: reactjs