<input type="file" @change="addImg" ref="inputer" multiple />
addImg(e) {
let inputDOM = this.$refs.inputer;
this.fil = inputDOM.files;
console.log(this.fil)
for (let i = 0; i < this.fil.length; i++) {
let size = Math.floor(this.fil[i].size / 1024);
if (size > 5 * 1024 * 1024) {
alert("请选择5M以内的图片!");
return false;
}
this.imgLen++;
this.$set(
this.imgs,
this.fil[i].name + "?" + new Date().getTime() + i,
this.fil[i]
);
}
},
网友评论