Material-UI 下一个 js Link 按钮
Material-UI Next js Link Button
我正在使用 Next-JS 和 Material-UI 构建服务器端渲染 React 项目。
我想申请 Material Ui button -> the Link with Dynamic routes
我该怎么做?我会apply React Router Link,但它是不同的...
我的问题是它需要其他属性,例如 "as" 属性.
什么对我有用(灵感来自 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>
编辑
开始 next.js
v10+ 你不需要指定 as
和 Automatic `href` Resolution 所以上面的代码可以写成:
<Link
href={'/static/' + someJsString}
passHref>
<Button
component="a">
// other component ...
</Button>
</Link>
我正在使用 Next-JS 和 Material-UI 构建服务器端渲染 React 项目。 我想申请 Material Ui button -> the Link with Dynamic routes
我该怎么做?我会apply React Router Link,但它是不同的...
我的问题是它需要其他属性,例如 "as" 属性.
什么对我有用(灵感来自 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>
编辑
开始 next.js
v10+ 你不需要指定 as
和 Automatic `href` Resolution 所以上面的代码可以写成:
<Link
href={'/static/' + someJsString}
passHref>
<Button
component="a">
// other component ...
</Button>
</Link>