Skip to content

预期 src 是一个图片。

ExpectedImage:getImage<Image />src 属性应为 ESM 导入的图片或带有远程图片路径的字符串。收到 SRC(类型:TYPEOF_OPTIONS)。

收到完整序列化选项:FULL_OPTIONS

¥ExpectedImage: Expected src property for getImage or <Image /> to be either an ESM imported image or a string with the path of a remote image. Received SRC (type: TYPEOF_OPTIONS).

Full serialized options received: FULL_OPTIONS.

¥What went wrong?

图片的 src 属性无效。图片组件要求 src 属性是已导入 ESM 的图片或字符串。对于 getImage() 的第一个参数也是如此。

¥An image’s src property is not valid. The Image component requires the src attribute to be either an image that has been ESM imported or a string. This is also true for the first parameter of getImage().

---
import { Image } from "astro:assets";
import myImage from "../assets/my_image.png";
---
<Image src={myImage} alt="..." />
<Image src="https://example.com/logo.png" width={300} height={300} alt="..." />

大多数情况下,当传递给 src 的值未定义时,就会发生此错误。

¥In most cases, this error happens when the value passed to src is undefined.

也可以看看:

¥See Also:

Astro 中文网 - 粤ICP备13048890号