Vue组件之v-viewer实现图片预览和缩放鼠标可随意拖拽

实现效果:

Vue组件之v-viewer实现图片预览和缩放鼠标可随意拖拽_第1张图片

 1.在npm引入v-viewer组件

npm install v-viewer

2.在main.js中配置

//导入图片预览viewer组件以及css
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.在template中写入标签

你可能感兴趣的:(vue.js,javascript,前端)