# hevue-img-preview **Repository Path**: ihope_top/hevue-img-preview ## Basic Information - **Project Name**: hevue-img-preview - **Description**: 本组件是一个基于 vue 编写的vue图片预览组件,支持单图和多图预览,仅传入一个图片地址,即可实现图片预览效果,比较适合给文章及页面的所有图片添加预览效果,预览背景色,关闭按钮颜色,控制条的背景也和字体颜色都可自定义,兼容 ie9+,火狐,Safari,谷歌浏览器,支持多图预览。如果能帮上你,希望可以给个小星星,如果有任何使用意见或建议,也欢迎回复或者提交issure - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 79 - **Forks**: 8 - **Created**: 2020-06-14 - **Last Updated**: 2025-09-15 ## Categories & Tags **Categories**: vue-extensions **Tags**: Vue, img-preview, vue-img, 图片预览, vue3 ## README ## hevue-img-preview 简介
```javascript // 增加功能: 图片预览图使用thumbnail图 const handleClick = (filePath: string) => { const imgs = tableData.value.filter((item: any) => !isVideo(item.filePath)).map((item: any) => item.filePath); const thumbnails = tableData.value .filter((item: any) => !isVideo(item.filePath)) .map((item: any) => item.thumbnailPath); const index = imgs.findIndex((item: any) => item === filePath); previewImages({ imgList: imgs, thumbnailsList: thumbnails, nowImgIndex: index > -1 ? index : 0 }); }; ``` 中文 | [English](./README.en.md) hevue-img-preview是一个基于 vue 编写的 vue 图片预览组件,已对vue2和vue3同时兼容,支持 pc 和手机端,支持单图和多图预览,仅传入一个图片地址,即可实现图片预览效果。手机端支持单指拖拽和双指缩放。页面各组件颜色均可自定义,实现个性化设计,如果能帮上你,希望可以移步 [GitHub](https://github.com/heyongsheng/hevue-img-preview) ,或者[码云](https://gitee.com/ihope_top/hevue-img-preview) 给个小星星,如果有任何使用意见或建议,也欢迎回复或者提交 issure 特色: `单图预览` `多图预览` `单图预览` `缩略图` `快捷键` `自定义旋转` `切换图片事件回调` `关闭事件回调` `PC端` `移动端` `保存图片` `自定义样式` ## 官方文档 > 中国用户请访问 [https://img-preview-doc.it1996.com](https://img-preview-doc.it1996.com) > 国际用户请访问 [https://heyongsheng.github.io/en](https://heyongsheng.github.io/en) > 本文档仅介绍部分使用方式,更多请访问官方文档 ## 安装 使用npm进行安装 ```bash npm install hevue-img-preview ``` 在main.js进行全局引入 ```javascript // vue2.x import hevueImgPreview from 'hevue-img-preview/v2' Vue.use(hevueImgPreview) // vue3.x import hevueImgPreview from 'hevue-img-preview/v3' const app = createApp(App) app.use(hevueImgPreview) app.mount('#app') ``` ## 使用 在组件中进行使用 ***vue2*** ```html