小编yth*_*aut的帖子

NextJS getStaticProps() 从未被调用

我正在制作一个简单的网站,我想从 API 获取数据并将其显示在我的组件上。问题是该getStaticProps()方法从未被调用。

这是该组件的代码:

import React from "react";
import {GetStaticProps, InferGetStaticPropsType} from "next";

type RawProject = {
    owner: string;
    repo: string;
    link: string;
    description: string;
    language: string;
    stars: number;
    forks: number;
}

function Projects({projects}: InferGetStaticPropsType<typeof getStaticProps>) {
    console.log(projects);
    return (
        <section id="projects" className="bg-white p-6 lg:p-20">
            <h1 className="sm:text-4xl text-2xl font-medium title-font mb-4 text-gray-900 pb-6 text-center">
                Quelques de mes projets
            </h1>
            {/*
            <div className="container px-5 mx-auto">
                <div className="flex flex-wrap">
                    {rawProjects.map((project: RawProject) => (
                        <ProjectCard
                            title={project.repo}
                            language={project.language}
                            description={project.description}
                            imageUrl="https://dummyimage.com/720x400"
                            repoUrl={project.link}
                        /> …
Run Code Online (Sandbox Code Playgroud)

typescript next.js

4
推荐指数
1
解决办法
5412
查看次数

标签 统计

next.js ×1

typescript ×1