1.在vue项目中安装v-viewer
使用npm安装:
npm install v-viewer
2.在vue中的main.js引入:
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use(Viewer);
Viewer.setDefaults({
Options: { "inline": true, "button": true, "navbar": true, "title": true, "toolbar": true, "tooltip": true, "movable": true, "zoomable": true, "rotatable": true, "scalable": true, "transition": true, "fullscreen": true, "keyboard": true, "url": "data-source" }
});
3.在项目中使用v-viewer
<viewer :images="fiellists">
<img
v-for="(imgItem, imgIndex) in fiellists"
:key="imgIndex"
class="previewImg"
:src="imgItem.file"
alt=""
width="80"
height="80"
/>
</viewer>