我在 next.config.js 中编写了下面的代码
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: [
'images.unsplash.com',
'hydeparkwinterwonderland.com',
'wembleypark.com']
},
]
}
}
module.exports = nextConfig
Run Code Online (Sandbox Code Playgroud)
但它会抛出这样的错误:
- The value at .images.remotePatterns[0].hostname must be a string but it was an array.
See more info here: https://nextjs.org/docs/messages/invalid-next-config
Run Code Online (Sandbox Code Playgroud)
Error: Invalid images.remotePatterns values:
{"protocol":"https","hostname":["images.unsplash.com","hydeparkwinterwonderland.com","wembleypark.com"]}
remotePatterns value must follow format { protocol: 'https', hostname: 'example.com', port: '', pathname: '/imgs/**' }.
See more info here: https://nextjs.org/docs/messages/invalid-images-config
Run Code Online (Sandbox Code Playgroud)
正在寻找答案,我是新手,请耐心等待
next.js ×1