【发布时间】:2019-08-02 22:43:50
【问题描述】:
要转到,我在Gatsby 中使用的competition page 这个函数,要转到那个页面:
gatsby-node.js
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions
if (page.path.match(/^\/competition/)) {
page.matchPath = "/competition/*"
createPage(page)
}
}
来自competition page,我正在返回Game component:
return <Game path="/competition/:id" myid={ props.id }/>
然后在Game component 内,我正在渲染一个按钮以转到频道页面:
<span className={style.button}>
<Link to={'/competition/'+this.props.myid+'/'+rowdata['GameName']}/>
</span>
在这里我不知道如何去channel page 我在src/pages 里面并保持我的网址像代码中一样:/competition/'+myid+'/'+GameName
我的方法正确吗? 我愿意接受其他解决方案
更新: 我可以接受这样的 url:
<span className={style.button}>
<Link to={'/competition/'+this.props.myid+'/channel'}/>
</span>
【问题讨论】:
标签: javascript reactjs url-routing gatsby