关于vue.js:axios发送multipartformdata请求

7次阅读

共计 435 个字符,预计需要花费 2 分钟才能阅读完成。

1. 开发环境 vue
2. 电脑系统 windows10 专业版
3. 在数据申请的过程中, 咱们可能会遇到后端须要 multipart/form-data 这样的格局, 那么前端如何实现呢?
4. 废话不多说, 办法如下:

let formData = new FormData();
      const param = {
        account: this.$store.state.account,
        nickname: this.form.Yournickname,
        remark: this.form.Introductiontothe,
      };

      formData.append("param", JSON.stringify(param));
      console.log(formData);
      accountconfig(formData).then((res) => {console.log(res);
      });
// 留神: 后端须要的参数格局 


5. 应用这种办法, 想后端传递的成果为:

6. 本期的分享到了这里就完结了, 心愿对你有所帮忙, 让咱们一起致力走向巅峰。

正文完
 0