vue+elementui组件图片上传时。将数据和图片一起提交

直接上图vue+elementui组件图片上传时。将数据和图片一起提交_第1张图片

 

vue+elementui组件图片上传时。将数据和图片一起提交_第2张图片

   

        

           

          

            class="upload-demo"

            action=""

            :headers="dataObj"

            :on-preview="handlePreview"

            :on-remove="handleRemove"

            :before-upload="beforeUpload"

            :file-list="fileList"

            list-type="picture">

       

            点击上传

            只能上传jpg/png文件,且不超过500kb

          

        

        

          保存

        

      

 

 

 

  submitFile(){

    

      const formData = new FormData()

      formData.append('file', this.uploadFile)

      axios({

        method: 'put',

        url: '/shopGroup/updateImage/' + this.editShopImg.id,

        data: formData,

        headers: {

          Authorization:Cookies.get("loginToken")

        }

      }).then(res => {

        console.log(res.data,"res.data")

        this.dialogVisibleShopImg=false

         if(res.data.code == 200 & res.data.success == true){

              this.$message({

                message: "提交成功",

                type: "success"

              

              });

            }else {

              this.$message({

                message: "保存失败",

                type: "error"

              });

            }

      })

    },

以此做记录

你可能感兴趣的:(vue学习,vue.js)