Skip to content

preview-image 简易图片预览

preview-image 是一个轻量级的图片预览组件,支持手势缩放。

基础用法

vue
<template>
  <preview-image 
    ref="previewImage" 
    :urls="imageList" 
    @onLongpress="onLongPress"
  >
  </preview-image>
</template>

<script>
export default {
  data() {
    return {
      imageList: ['https://example.com/1.jpg', 'https://example.com/2.jpg']
    }
  },
  methods: {
    openPreview(url) {
      this.$refs.previewImage.open(url);
    },
    onLongPress(url) {
      console.log('长按图片:', url);
    }
  }
}
</script>

Props

参数说明类型默认值
urls图片地址数组Array[]

Methods

方法名说明参数
open打开预览(currentUrl: String)
close关闭预览-

Events

事件名说明回调参数
open打开时触发-
close关闭时触发-
onLongpress长按图片时触发(url: String)