Appearance
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) |