图片上传

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)

    },

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容