我正在开发一个使用 Next-JS 和 Material-UI 构建的服务器端渲染 React 项目。
我想应用到 Material Uibutton https://material-ui.com/api/button/-> 的与动态路线链接 https://nextjs.org/docs/api-reference/next/link#dynamic-routes
我怎样才能做到这一点?我会应用 React Router 链接 https://material-ui.com/guides/composition/#button,但是不一样...
我的问题是它需要另一个属性,例如“as”属性。
什么对我有用(灵感来自Github 上的这条评论 https://gist.github.com/herr-vogel/0b5d4f3c28f08dc6cc4a2fd4f7b4a4df#gistcomment-3070513):
<Link
href={'/static/[dynamic]'}
as={'/static/' + someJsString}
passHref>
<Button
component="a">
// other component ...
</Button>
</Link>
对于版本v10+
:
<Link
href={`/static/${someJsString}`}
passHref>
<Button
component="a">
// other component ...
</Button>
</Link>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)