axios post提交数据格式不对的问题

需要格式化一下

this.$http({
        method: "post",
        url: "/chinacountry/index.php/home/Search/index",
        data: {
          search: this.search_text
          //search_i: "2"
        },
        transformRequest: [
          function(data) {
            let ret = "";
            for (let it in data) {
              ret +=
                encodeURIComponent(it) +
                "=" +
                encodeURIComponent(data[it]) +
                "&";
            }
            ret = ret.slice(0, -1); // 去掉最后的空行
            return ret;
          }
        ],
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        }
      })
        .then(response => {
          console.log(response);
        })
        .catch(error => {
          console.log(error);
        });
原文地址:https://www.cnblogs.com/chenzeyongjsj/p/8109740.html