引入

import axios from "axios";

请求位置

  axios
    .post(
      url,
      {
        comtents:this.con,
        relationNum:this.value
      },
      {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        //transformRequest允许在向服务器发送前,修改请求数据
        transformRequest: [
          function(data) {
            let ret = "";
            for (let it in data) {
              ret +=
                encodeURIComponent(it) +
                "=" +
                encodeURIComponent(data[it]) +
                "&";
            }
            return ret;
          }
        ]
      }
    )
    .then(res => {
      console.log(res.data); //返回的数据
    })
    .catch(err => {
      console.log(err);
      that.$toast.fail("网络请求失败");
    });
Logo

前往低代码交流专区

更多推荐