Vue插件图片预览hevue-img-preview
安装
# 安装
npm install hevue-img-preview --save
# main.js 引入
import hevueImgPreview from 'hevue-img-preview'
Vue.use(hevueImgPreview)
# 使用
#//给任意对象添加任意事件,例如
<img :src="imgurl" @click="previewImg(imgurl)">
#//在事件里调用方法进行预览
methods: {
previewImg (imgurl) {
this.$hevueImgPreview(imgurl)
}
}
使用
//接收一个地址字符串
this.$hevueImgPreview(url)
this.$hevueImgPreview('https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg') // 线上地址
this.$hevueImgPreview('./img/logo.jpeg') // 本地地址
//接收一个对象
this.$hevueImgPreview(options)
单图预览
this.$hevueImgPreview({
url: 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
mainBackground: 'rgba(0, 0, 0, .5)', // 整体背景颜色
})
多图预览
this.$hevueImgPreview({
multiple: true, // 开启多图预览模式
nowImgIndex: 1, // 多图预览,默认展示第二张图片
imgList: ['1.png', '2.png', '3.png'], // 需要预览的多图数组
mainBackground: 'rgba(0, 0, 0, .5)', // 整体背景颜色
})
如果这篇文章对你有用,可以关注本人微信公众号获取更多ヽ(^ω^)ノ ~

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
2022-04-28 Python常用函数
2018-04-28 ActiveMQ