图片压缩
<input type="file" id="file" @change="changeFile()" accept="image/jpeg,image/gif,image/png" multiple="multiple" style="opacity: 0;">
changeFile() {
var that = this;
var Files = document.getElementById('file').files[0];
this.uploadSectionFile(Files);
},
uploadSectionFile(f) { // 附件上传
let that = this;
let Orientation;
let ndata;
let url;
if (f.size <= 1 * 1024 * 1024) {
//判断图片是否大于1M,是就直接上传
ndata = f;
that.uploadimg = ndata;
that.show = true;
} else {
//反之压缩图片
let reader = new FileReader();
// 将图片2将转成 base64 格式
reader.readAsDataURL(f);
// 读取成功后的回调
reader.onloadend = function () {
let result = this.result;
let img = new Image();
img.src = result;
img.onload = function () {
ndata = that.com