vue中用H5实现文件上传的方法实例代码
发布时间:2020-12-17 02:56:34 所属栏目:百科 来源:网络整理
导读:整理文档,搜刮出一个vue中用H5实现文件上传的方法实例代码,稍微整理精简一下做下分享。 1.图片上传 fileSize) { that.$dispatch('show-alert','msg_1016') document.getElementById('fileToUpload').value = '' } else { var xhr = new XMLHttpRequest() x
整理文档,搜刮出一个vue中用H5实现文件上传的方法实例代码,稍微整理精简一下做下分享。 1.图片上传 fileSize) {
that.$dispatch('show-alert','msg_1016')
document.getElementById('fileToUpload').value = ''
} else {
var xhr = new XMLHttpRequest()
xhr.addEventListener('load',that.uploadComplete,false)
xhr.open('POST',that.$root.appBaseUrl + 'fileUpload/singleFileUpload')
xhr.send(fd)
}
}
}
},// 上传成功
'uploadComplete': function (evt) {
this.personInfo.photoUrl = (evt.target.responseText).replace('','/')
document.getElementById('fileToUpload').value = ''
},// 删除图片
'deleteImg': function () {
this.personInfo.photoUrl = ''
},
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |