Material-UI Next js 链接按钮 [英] Material-UI Next js Link Button
本文介绍了Material-UI Next js 链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个使用 Next-JS 和 Material-UI 构建的服务器端渲染 React 项目.我想申请 Material Ui button -> 链接动态路由
I am working on a Server-Side-Rendering React Project, built with Next-JS and Material-UI. and i want to apply To Material Ui button -> the Link with Dynamic routes
我该怎么做?我会应用反应路由器链接,但它是不同的...
how can i do this? i would apply React Router Link,but it is different...
我的问题是它需要其他属性,例如as"属性.
my problem is that it has another properties required such as "as" property.
推荐答案
什么对我有用(灵感来自 Github 中的此评论):
what worked for me (inspired from this comment in Github):
<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>
这篇关于Material-UI Next js 链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文