axios模拟表单提交

axios模拟表单提交

	url: 'url地址',
    method: 'post',
    data: {
      username: username,
      password: password
    },
    // 提交前更改格式
    transformRequest: [function(data) {
      let ret = ''
      for (const it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    // 携带表单请求头
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
    }

猜你喜欢

转载自blog.csdn.net/weixin_42282391/article/details/89552436