预期图片选项,而不是 ESM 导入的图片。
ExpectedNotESMImage:ESM 导入的图片不能直接传递给
getImage()。相反,在src属性中传递一个带有图片的对象。¥ExpectedNotESMImage: An ESM-imported image cannot be passed directly to
getImage(). Instead, pass an object with the image in thesrcproperty.
什么地方出了错?
Section titled “什么地方出了错?”¥What went wrong?
ESM 导入的图片不能直接传递给 getImage()。相反,在 src 属性中传递一个带有图片的对象。
¥An ESM-imported image cannot be passed directly to getImage(). Instead, pass an object with the image in the src property.
import { getImage } from "astro:assets";import myImage from "../assets/my_image.png"; const optimizedImage = await getImage( myImage ); const optimizedImage = await getImage({ src: myImage });也可以看看:
¥See Also:
Error Reference