1、base64预览+接口返回服务器路径预览
async changePic (name) {
const fileDocument = this.$refs[name]
let file = fileDocument.files[0]
let param = new FormData()
param.append('image', file)
param.append('imgType', 'file')
console.log(param.get('file'))
let config = {
headers: {'Content-Type': 'multipart/form-data'}
}
this.$_post('/addPictures.json', param, config).then(response => {
console.log(response.imgPath)
console.log(33333333333)
this.targetImg[name] = response.imgPath
})
// 获取bease64本地预览
// let file = this.$refs[name]
// this.targetReader[name] = new FileReader()
// this.targetReader[name].onload = (evt) => {
// this.targetImg[name] = evt.target.result
// }
// console.log(333333333333)
// this.targetReader[name].readAsDataURL(file.files[0])
// // this.targetReader[name].readAsText(file[0])
// console.log(this.$refs.formEnterprise)
},
网友评论