/标签不起作用。不同于本教程,编译后没有显示任何内容。
我一直关注Nextjs.org上的教程,并且还将typescript版本与create-next-app typescript一起使用。经过一堆类型的努力之后,我终于可以编译了,但是看到的是空白的组件。 当我看着控制台时,它说 index.js:1警告:不建议使用'url'属性。 https://err.sh/zeit/next.js/url-deprecated
我单击了链接,我也按照说明进行操作,甚至下载了codemod,也没有任何反应,有人知道我现在应该做什么吗?非常感谢你!
import * as React from "react";
import Layout from '../components/MyLayout'
import Link from "next/link";
import {withRouter} from 'next/router'
interface IPostLinkProps{
title:string
}
const PostLink = (props:IPostLinkProps) =>{
return(
<li>
<Link href={`/post?title=${props.title}`}>
<a>{props.title}</a>
</Link>
</li>
)
}
export default withRouter(function Blog(){
return(
<Layout>
<h1> My Blog</h1>
<ul>
<PostLink title='hi'/>
<PostLink title="HELP!"/>
<PostLink title='hi'/>
</ul>
</Layout>
)
})
index.js:1警告:不建议使用'url'属性。 https://err.sh/zeit/next.js/url-deprecated
答案 0 :(得分:0)
使用useRouter可能会获得帮助 从'next / router'导入{useRouter};
答案 1 :(得分:0)
试试这个:
python3 record_audio.py
然后这样称呼它:
interface IProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
label: string
}
export default function Link({children, href, label, ...rest}: IProps) {
return <NextLink passHref {...{href}}>
<a {...rest}>{label ?? children}</a>
</NextLink>
}
或
<Link href='/' label='Home'/>