【问题标题】:What does NextPage in Next.js do?Next.js 中的 NextPage 有什么作用?
【发布时间】:2022-01-14 02:31:05
【问题描述】:

我刚开始在 Next 中使用 TypeScript。这是做什么的? import { NextPage } from 'next'; export const Page: NextPage = () => {} 我查看了文档,但它确实很好地解释了它的作用。

我猜它路由页面的名称。 有人可以解释一下这是做什么的吗?

谢谢。

【问题讨论】:

    标签: javascript reactjs typescript next.js tsx


    【解决方案1】:

    我的建议是开始here,但简而言之:

    import { NextPage } from 'next';
    
    export const Page: NextPage = () => {}
    

    NextPage 是 NextJS 导出的类型。当我们写 Page: NextPage 时,我们是在说我们的 Page 组件的类型是 NextPage

    【讨论】:

    • 哦,我明白了......我们正在为页面分配类型......所以所有将成为页面(在 JS 中)的东西都将成为 TS 中的 NextPage......
    猜你喜欢
    • 1970-01-01
    • 2018-06-02
    • 2021-11-22
    • 1970-01-01
    • 2021-05-27
    • 2021-04-27
    • 2019-04-29
    • 2020-08-26
    • 1970-01-01
    相关资源
    最近更新 更多