上传图片
将图片长传到oss时注意的事项,
<input type="file" @change="imgChange($event)" ref="int">
encodeURIComponent是将base64的图片进行编码,防止上传到oss的图片不完整,
imgChange (ev) {
let reader = new FileReader(),
img1 = ev.target.files[0],
that = this;
this.img_type = 'data:' + img1.type + ';base64,';
reader.readAsDataURL(img1);
reader.onload = function (e) {
that.skmimg = encodeURIComponent(this.result);
}
this.$refs.int.value = '';
},