我将VScode用作IDE,将withRouter
的通用名称应应用在props.router.query上,但不起作用
试图创建组件接口并使用withRouterProps进行扩展,但使用props.router.query。仍然什么也没显示
import { withRouter, WithRouterProps } from 'next/router';
import Layout from '../components/Layout';
import React from 'react';
class Page extends React.Component<IPageProps> {
render() {
console.log(this.props.router.query.); <=== should show title in intellience but nothing happened
return (
<Layout>
{/* <h1>{this.props}</h1> */}
<p>This is the blog post content.</p>
</Layout>
);
}
}
export default withRouter(Page);
interface IPageProps extends WithRouterProps<{ title: string }> {
test: string;
}
通用应该发生。
即withRouterProps<{ title: string }>
应该设为props.router.query.title works