Open Riunshow opened 5 years ago
<input ref="inputFile" type="file" @change="onUploadImg" v-if="!disabled" :accept="accept" />
// 上传图片 onUploadImg (event) { let imgBlob = null const img = event.target.files[0] const reader = new FileReader() reader.readAsArrayBuffer(img) reader.onload = function () { imgBlob = new Blob([this.result]) this.uploadMethod(imgBlob) } // this.cropperImg = URL.createObjectURL(img) },
request
let data = { content: blob, tenant: '', domain: this.domain } uploadPic (url, data, header) { let formData = new FormData() let keys = Object.keys(data) keys.forEach(key => { formData.append(key, data[key]) }) return axios.post(url, formData, { headers: { 'Content-Type': 'multipart/form-data', ...header } }) }
request