VUE(Upload) 上传图片

  • template
                  
                    <i class="el-icon-plus">i>
                  el-upload>
  • methods
	fail (file) {
      this.dialogImageUrl = file.url
      console.log('我是fail')
      this.uploadimg = file.raw
      console.log(this.uploadimg)
    },
    uploadImg(){
      // UploadFile
      console.log(77777777777)
      let formData2 = new FormData()

      formData2.append('BookImg', this.uploadimg)
      formData2.append('Id', this.formValidate.ISBN)
      formData2.append('AttachmentClass', '11')

      UploadFile(formData2)
        .then(res=>{
          console.log(8989898989989)
          console.log(res)
        })
        .catch(err => {
          this.$Message.error('图片上传失败!')
        })
    },

具体细节看这篇博客
VUE上传图片

你可能感兴趣的:(vue,vue,upload)