【发布时间】:2020-11-25 17:02:43
【问题描述】:
为什么以下内容会从 amp 呈现的页面中排除?
- 反应生命周期方法
- 响应回调,如 onClick
- 反应钩子
我真正的问题是,如果我在此页面上启用 AMP(取消注释第 3 行),将不会打印 router.query.title。
import { useRouter } from 'next/router';
import withLayout from 'components/MyLayout';
//export const config = { amp: true };
const Content = () => {
const router = useRouter();
return (
<React.Fragment>
<h1>{router.query.title}</h1>
<p>This is the blog post content.</p>
</React.Fragment>
);
};
const Page = () => (
<Content />
)
export default withLayout(Page);
【问题讨论】: