Vue.js项目中使用 Ajax 和 FormDate 对象上传文件


let param = new FormData();

param.append("paths", this.ruleForm.uploadPath);

param.append("pkg", this.ruleForm.packageName);

//      param.append("file", $('#file')[0].files[0]);

 

this.$http({

  method: 'post',

  url: 'http://upload.com/doapi',

  data: param

}).then(res => {

  res = res.data;

  if(res.errorcode === 0) {

//  console.log(res)

    this.$message({

      message: res.msg,

      type: 'success'

    })

  } else {

    this.$message({

      message: res.msg,

      type: 'error'

    })

  }

});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM