流浪のwolf

卷帝

导航

element的upload 图片上传主函数

  

  /** 图片上传 */
    async UploadImage (event, file, filelist) {
      // 清空坐标
      this.formModel.ITEM_XY = [0, 0]
      this.imgX = 0
      this.imgY = 0
      let fd = new FormData()
      fd.append("file", file.raw) //传给后台接收的名字 file
      // 调用接口获取的线上地址
      const res = await api.baseData.uploadFiles(fd)
      this.imageUrl = res.url
      if (res.code === 200) {
        this.formModel.ITEM_IMAGE = res.url
      }
      // 生成了临时地址
      this.imageUrl = URL.createObjectURL(file.raw)
    },

 

posted on 2023-03-20 13:30  流浪のwolf  阅读(10)  评论(0编辑  收藏  举报