开发工具webstorm
首先npm安装插件:npm install viewerjs
然后再main.js中引用
import Viewer from 'v-viewer'import 'viewerjs/dist/viewer.css'/* eslint-disable */Vue.use(Viewer)Viewer.setDefaults({Options: {"inline": true, "button":true, "navbar": true, "tittle": true, "toolbar":true, "tooltip": true, "movable": true, "zoomable": true, "rotatable": true, "scalable": true, "transition": true, "fullscreen": true, "keyboard": true, "url": "data-source" }})
然后在需要图片预览的地方添加viewer标签
<el-table-column prop="img" label="图片" header-align="center" align="center"><template slot-scope="scope"><viewer :images="imgArr"><img style="width: 60px;height: auto" :src="scope.row.img" alt=""></viewer></template></el-table-column>
如果是单图片的话 :images属性可以去除
如果觉得《vue点击预览图片插件(可放大缩小翻转等)》对你有帮助,请点赞、收藏,并留下你的观点哦!