我有一堆图像-确切地说是230个图像,我想使用getStaticProps预加载这些图像。但是,我不知道如何使用for循环预加载它们,因为当我试图在控制台中调用它时,最终结果是未定义的。
export async function getStaticProps() {
frameCount = 230
for (let id = 1; id < frameCount; id++) {
const res = await fetch (`https://${VERCEL_URL}/_next/image?url=%2F${id}.webp&w=1080&q=90`)
我想遍历React代码中的对象数组。我正在使用getStaticProps()从一个在线的假API服务器获取数据。 我的代码使用了nextjs。如何使用for或while或任何循环来完成此操作? import Head from 'next/head'
export async function getStaticProps() {
const res = await fetch('https://jsonplaceholder.typicode.com/todos')
const data = await res.json()
我正在使用NextJs制作一个web应用程序。在页面中,我需要获取一个api来获取数据并显示它。但是它编译了我有一个错误。
错误是:Error: Your `getStaticProps` function did not return an object. Did you forget to add a `return`?
我的职责是:
export async function getStaticProps(context) {
try {
const res = await fetch(ApiLinks.players.all)
.then((resp
这是我第一次发问。你好,我是nextjs的新手,我正在与django、drf和postgres一起使用它。问题是,我不能使用在profile.js文件之上导入getStaticProps的‘js’,getServerSideProps也不像这样:
我的进口:
import Cookies from 'js-cookie'
import jwt_decode from 'jwt-decode'
我的用例在getStaticProps/getServerSideProps中,当我使用console.log(令牌)时,它返回未定义的:
我的用例不是在getSta