Skip to content

Image 图片

用于展示图片的组件,支持模糊加载和 Live Photo 模式。

基础用法

vue
<template>
  <Image :src="imgInfo.url" :data="imgInfo" alt="示例图片" />
</template>

<script setup>
import { ref } from 'vue'
import { Image } from 'l-preview' 
import 'l-preview/dist/style.css'

const imgInfo = ref({
  "file": "https://nest-js.oss-accelerate.aliyuncs.com/nestTest/1/1711965193523.JPEG",
  "fileType": "IMAGE",
  "thumbnail": "https://nest-js.oss-accelerate.aliyuncs.com/nestTest/1/1711965193523.JPEG?x-oss-process=image/resize,l_500"
 "blurhash": "LA8%6~xttUg500XTf-oe_LjYada}",
  "videoSrc": "https://nest-js.oss-accelerate.aliyuncs.com/nestTest/1/1711965199299.MOV",
})
</script>

API

Props

参数说明类型默认值
data图片数据对象Object-
isShowOrigin是否直接展示原图booleanfalse
delay加载延时number1000
mode加载模式(blurhash 或 normal)string'blurhash'
isLive是否开启 Live Photo 模式booleanfalse
position图片位置Object'{ x: 0, y: 0 }'
scale图片缩放比例number1
rotation图片旋转角度number0
isDragging是否拖拽中booleanfalse

Events

事件名说明回调参数
imageLoaded图片加载完成时触发'{ naturalWidth: number, naturalHeight: number }'