博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue 图片预览插件
阅读量:4655 次
发布时间:2019-06-09

本文共 1088 字,大约阅读时间需要 3 分钟。

https://github.com/daidaitu1314/vue2-preview

 

//cnpmcnpm install vue2-preview -save//引入import VuePreview from 'vue2-preview'Vue.use(VuePreview)

 

            list: [{                      src: 'https://placekitten.com/600/400',                      w: 600,                      h: 400                }, {                      src: 'https://placekitten.com/1200/900',                     w: 1200,                      h: 900                }],

图片宽度自适应

//插件里写imgload获取图片宽高                onRead(file) {                      let img = new Image();                       img.src = file.content;                      let that = this;                      img.onload = function () {   // 图片的宽高要做onload后才能获取到                        that.imgList.push({                              src:file.content,                              msrc:file.content,                              title: "图片",                              w: img.width,                              h: img.height                        })                      }                 },

 

转载于:https://www.cnblogs.com/tanxiang6690/p/9878808.html

你可能感兴趣的文章
CSS选择器总结
查看>>
mysql中sql语句
查看>>
sql语句的各种模糊查询语句
查看>>
C#操作OFFICE一(EXCEL)
查看>>
【js操作url参数】获取指定url参数值、取指定url参数并转为json对象
查看>>
移动端单屏解决方案
查看>>
web渗透测试基本步骤
查看>>
使用Struts2标签遍历集合
查看>>
angular.isUndefined()
查看>>
第一次软件工程作业(改进版)
查看>>
网络流24题-飞行员配对方案问题
查看>>
引入css的四种方式
查看>>
iOS开发UI篇—transframe属性(形变)
查看>>
3月7日 ArrayList集合
查看>>
jsp 环境配置记录
查看>>
Python03
查看>>
LOJ 2537 「PKUWC2018」Minimax
查看>>
使用java中replaceAll方法替换字符串中的反斜杠
查看>>
Some configure
查看>>
流量调整和限流技术 【转载】
查看>>