1、项目结构
idcard.js
export default{
install(Vue) {
Vue.prototype.$scaleimg = function (img) {
let height=img.currentTarget.height;
let width=img.currentTarget.width;
let base64data='';
let can=document.createElement("canvas");
can.height=height;
can.width=width;
let casimg=can.getContext('2d');
casimg.clearRect(0, 0,width,height);
casimg.drawImage(img.currentTarget,0,0,width,height);
base64data=can.toDataURL('image/*');
let size=Math.round( this.$dataURLtoBlob(base64data).size/1024);
let maxsize=800;
if(size>maxsize){
if(size<1300){