vue elemnt upload 提交带参数

html

  <el-upload class="avatar-uploader" action="http://yjyhnav1.rdmate.com/ad_admin/" :http-request="upLoad" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
                  <img v-if="headUrl" :src="headUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
js
 upLoad(file) {
      const formData = new FormData();
      formData.append('logo', file.file);
      formData.append('activity_id', this.activity_id);
      console.log(file, "上传的图片");
//发送请求
      LOGO(
        formData
      ).then(res => {
        //  that.imgId = res.data.data
        Bus.$emit('logourl', res.data.logo.url)
        this.headUrl = res.data.logo.url

      }).catch((error) => {
        // this.$message.error('头像上传失败,请重新上传!');

      })

    },
 beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt3M = file.size / 1024 / 1024 < 3;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt3M) {
        this.$message.error('上传头像图片大小不能超过 3MB!');
      }
      return isJPG && isLt3M;
    },
 handleAvatarSuccess(res, file) {
      this.headUrl = URL.createObjectURL(file.raw);

    },
正道的光终将来临,当太阳升起的时候,光芒总会普照大地温暖人间。些许的阴霾也终会有被阳光洒满的一天
原文地址:https://www.cnblogs.com/sjruxe/p/14486351.html