Vue图片预览插件viewerjs

news/2024/7/10 1:54:53 标签: 前端, viewer.js, Vue

Vueviewerjs_0">Vue图片预览插件viewerjs

安装

npm install v-viewer

引入插件

//main.js文件
import Vue from "vue";
import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";
//属性配置
Vue.use(Viewer, {
  defaultOptions: {
    'inline':true,//自动缩放
    'button':true, //右上角按钮
    "navbar": true, //底部缩略图
    "title": true, //当前图片标题
    "toolbar": true, //底部工具栏
    "tooltip": true, //显示缩放百分比
    "movable": true, //是否可以移动
    "zoomable": true, //是否可以缩放
    "rotatable": true, //是否可旋转
    "scalable": true, //是否可翻转
    "transition": true, //使用 CSS3 过度
    "fullscreen": true, //播放时是否全屏
    "keyboard": true, //是否支持键盘
    // "url": "data-source",//图片地址
    ready: function (e) {
      console.log(e.type,'组件以初始化');
    },
    show: function (e) {
      console.log(e.type,'图片显示开始');
    },
    shown: function (e) {
      console.log(e.type,'图片显示结束');
    },
    hide: function (e) {
      console.log(e.type,'图片隐藏完成');
    },
    hidden: function (e) {
      console.log(e.type,'图片隐藏结束');
    },
    view: function (e) {
      console.log(e.type,'视图开始');
    },
    viewed: function (e) {
      console.log(e.type,'视图结束');
      // 索引为 1 的图片旋转20度
      if(e.detail.index === 1){
          this.viewer.rotate(20);
      }
    },
    zoom: function (e) {
      console.log(e.type,'图片缩放开始');
    },
    zoomed: function (e) {
      console.log(e.type,'图片缩放结束');
    }
  }
});

.vue图片预览页面使用

<viewer :images="srcListImg" class="demo-image__preview">
	<img :src="item" alt="">
</viewer>
data() {
  return {
    images:[
      {src:'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3272199364,3404297250&fm=26&gp=0.jpg',index:1},
      {src:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3267295166,2381808815&fm=26&gp=0.jpg',index:2},
      {src:'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3429654663,2972188411&fm=26&gp=0.jpg',index:3},
      {src:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3597323878,2962972725&fm=26&gp=0.jpg',index:4},
    ]
  }
}`

在这里插入图片描述
注意:
底部导航工具栏toolbar修改:
toolbar Object详解
根据需求修改toolbar

Vue.use(Viewer, {
  defaultOptions: {
    'navbar': false, // 显示缩略图导航
    "toolbar": { "zoomIn":true, "zoomOut":true, "oneToOne":true, "reset":true, "prev": false, "play":false, "next":false, "rotateLeft":true, "rotateRight":true, "flipHorizontal":true, "flipVertical":true},
  }
});

在这里插入图片描述


http://www.niftyadmin.cn/n/1410105.html

相关文章

MinGW32和64位交叉编译环境的安装和使用

原文出处&#xff1a; CompileGraphics Magick, Boost, Botan and QT with MinGW64 under Windows 7 64 http://www.kineticsystem.org/?qnode/19 1 安装MSYS 从下面的地址下载并运行:mingw-get-inst-20120426.exe http://sourceforge.net/projects/mingw/files/Installer/min…

nosql和关系型数据库比较?

nosql和关系型数据库比较&#xff1f; 优点&#xff1a; 1&#xff09;成本&#xff1a;nosql数据库简单易部署&#xff0c;基本都是开源软件&#xff0c;不需要像使用oracle那样花费大量成本购买使用&#xff0c;相比关系型数据库价格便宜 2&#xff09;查询速度&#xff1a;…

微信小程序打开相机选择本地相册

img_w_show(){var _thisthis;wx.chooseImage({count: 9, // 默认9sizeType: [original, compressed], // 可以指定是原图还是压缩图&#xff0c;默认二者都有sourceType: [album, camera], // 可以指定来源是相册还是相机&#xff0c;默认二者都有success: function (res) {// …

设计模式六大原则(6):开闭原则

定义&#xff1a;一个软件实体如类、模块和函数应该对扩展开放&#xff0c;对修改关闭。 问题由来&#xff1a;在软件的生命周期内&#xff0c;因为变化、升级和维护等原因需要对软件原有代码进行修改时&#xff0c;可能会给旧代码中引入错误&#xff0c;也可能会使我们不得不对…

python scrapy 基础

scrapy是用python写的一个库&#xff0c;使用它可以方便的抓取网页。 主页地址http://scrapy.org/ 文档 http://doc.scrapy.org/en/latest/index.html 安装 sudo pip install scrapy 一个简单的教程 http://doc.scrapy.org/en/latest/intro/tutorial.html 如果你对这些概念有了…

小程序图片上传到服务器

updata() { var that this ; wx.chooseImage({ //微信封装的选择本地图片或相机拍照的API count : 1, //图片上传的数量 sizeType:[ original, compressed ], //上传图片的合法值&#xff0c;原图|压缩图 sourceType:[album, camera], //上传图片的方式 本地|相机 s…

中文分词器IK和Paoding技术对比

2019独角兽企业重金招聘Python工程师标准>>> 中文分词器IK和Paoding技术对比 博客分类&#xff1a; java 分词器 1. IK和Paoding的技术介绍 一、Ik分词器介绍&#xff1a; 优点&#xff1a; 采用了特有的“正向迭代最细粒度切分算法”&#xff0c;具有60万字…

用Scrapy抓取豆瓣小组数据

http://my.oschina.net/chengye/blog/124157