VUE图片预览放大缩小插件viewer

VUE图片预览放大缩小插件viewer

一、安装依赖

npm install v-viewer --save

二、main.js内引用并注册调用

//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" }
});

三、代码中使用

<template>
    <div class="content">
        <h1>Viewer图片预览插件</h1>
        <viewer :images="imgs">
            <img v-for="src in imgs" :src="src.url" :key="src.title">
        </viewer>
   </div>
</template>
<script>
export default {
    
    
  data () {
    
    
    return {
    
    
      imgs: [
       {
    
    
          url: 'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1547803398,3047886900&fm=26&gp=0.jpg',
          title: '图片1'
        },
        {
    
    
          url: 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1235440307,3142075557&fm=26&gp=0.jpg',
          title: '图片2'
        }
      ]
    }
  },
}
</script>

猜你喜欢

转载自blog.csdn.net/weixin_43923659/article/details/114261675