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