Image (图片)

带骨架屏、宽高比与 object-fit 的图片;在 Nuxt 层下经由 @nuxt/image 渲染。

基础用法

示例图片
Basic.vue

宽高比

16:9
1:1
AspectRatio.vue

填充方式

cover
cover
contain
contain
ObjectFit.vue

骨架屏

骨架屏示例
Skeleton.vue

ThumbHash 模糊占位(blur-up)

传入 thumbhash(后端随图片元数据下发的 ~25 字节 base64), 加载前即显示解码出的模糊占位、加载完成后淡出——比纯骨架屏更贴近最终画面,且零额外网络请求。 解码器仅在用到时才按需加载,客户端解码、SSR 安全。

ThumbHash 模糊占位示例
BlurUp.vue

加载失败回退

加载失败回退
Fallback.vue

load / error 事件

两个事件的签名都是 (src, event?)。第一个参数是对应的图片地址—— 因为配了 fallbackSrc 时会有两次尝试,靠它才能区分是原图失败还是回退图也失败。 event 是原生 DOM 事件;若失败/成功是从已缓存的图片状态直接判定出来的 (此时浏览器不会再触发 load / error),则为 undefined

加载失败即整体消失
正常图片
等待中…
ErrorEvent.vue

懒加载与即时加载

eager
eager(即时)
lazy
lazy(懒加载,默认)
Loading.vue

属性

属性类型默认值说明
src *string
altstring"image"
ariaLabelstringundefined
aspectRatiostringundefined
classNamestringundefined
decoding"auto" | "sync" | "async"undefined
densitiesstringundefined
fallbackSrcstringundefined
fetchpriority"auto" | "high" | "low"undefined
formatstringundefined
heightstring | numberundefined
imageClassNamestringundefined
loading"lazy" | "eager""lazy"
objectFit"fill" | "none" | "cover" | "contain" | "scale-down""cover"
placeholderstring | number | boolean | [w: number, h: number, q?: number, b?: number]undefined
preloadboolean | { fetchPriority: "auto" | "high" | "low"; }undefined
provider"none" | (string & {}) | "ipx"undefined
qualitystring | numberundefined
sizesstringundefined
skeletonbooleantrue
thumbhashstringundefinedA ThumbHash (base64) → a blurred "blur-up" placeholder shown until the image loads, then cross-faded out. Decoded to a tiny image on the client; falls back to the pulse skeleton until decoded (or if the hash is invalid). Implies the wrapper even with `skeleton: false`.
widthstring | numberundefined