Skip to content

Image

演示

Image 跨端示例与演示

Varo retail storefront
自适应封面cover · 16:9
填充模式
Varo
品牌头像
资源不可用

基础用法

vue
<template>
  <VImage src="/logo.png" width="96" height="96" fit="cover" radius="12px" />
</template>

填充模式

vue
<template>
  <VImage src="/logo.png" width="96" height="96" fit="contain" />
  <VImage src="/logo.png" width="96" height="96" fit="cover" />
  <VImage src="/logo.png" width="96" height="96" fit="fill" />
</template>

圆形图片

vue
<template>
  <VImage src="/logo.png" width="72" height="72" round />
</template>

加载与失败态

vue
<template>
  <VImage src="/not-found.png" width="96" height="96" error-text="加载失败" />
</template>

Props

Prop类型默认值描述
srcstringundefined图片地址
altstring''图片替代文本
widthnumber | stringundefined容器宽度
heightnumber | stringundefined容器高度
fit'contain' | 'cover' | 'fill' | 'none' | 'scale-down''fill'图片填充模式
positionstring'center'object-position
radiusnumber | stringundefined圆角
roundbooleanfalse是否圆形展示
lazyLoadbooleanfalse是否使用浏览器懒加载
showLoadingbooleantrue是否展示加载占位
showErrorbooleantrue是否展示失败占位
loadingTextstring''加载占位文案
errorTextstring''失败占位文案
draggableboolean | undefinedundefined是否允许拖拽图片

Events

EventPayload描述
loadEvent图片加载完成
errorEvent图片加载失败
clickMouseEvent点击图片容器

Slots

Slot描述
loading自定义加载占位
error自定义失败占位

Primitives

ImageRoot 分别由 @varo-ui/h5/primitives@varo-ui/weapp/primitives 提供;@varo-ui/headless 只承载共享状态契约,UI 包的 VImage 负责 Varo 类名和 API 包装。