微信小程序
1. 文件一:网络请求的服务配置 const config = { // 测试 baseUrl: 'https://+域名+/login', ....... } export default config 2. 文件二:请求处理的封装: function post(url, params, onSuccess, onFailed) { request(url, params, "POST", onSuccess, onFailed); } function get(url, params, onSuccess, onFailed) { request(url, params, "GET", onSuccess, onFailed); } /** * function: 封装网络请求 * @url URL地址 * @params 请求参数 * @method 请求方式:GET/POST * @onSuccess 成功回调 * @onFailed 失败回调 */ function request(url, params, method, onSuccess, onFailed) { wx.showLoading({ title: "正在加载中...", }) var header = { 'content-type': 'application/x-www-form