nodejsq发送formData的数据
axios({ method: 'post', url: 'http://localhost:8080/login', data: { username: obj.username, password: obj.passwd }, transformRequest: [ function (data) { let ret = '' for (let it in data) { ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' } ret = ret.substring(0, ret.lastIndexOf('&')); return ret } ], headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
安装 axios 模块,通过 import 引入即可使用