赞
踩
request.js放到项目的utils文件夹下:
import global from "@/global.js" export default (param) =>{ let url = global.apiUrl + param.url; let method = param.method; let data = param.data; //将param数据赋值给data let params = param.params; if (params) data = params; //头 let header = {} header["content-type"] = "application/json"; header["Authorization"] = 'Bearer ' + global.getApiToken();//token是登录若依的token //返回Promist return new Promise((resolve, reject) => { uni.request({ url: url, method: method, data: data, header: header, success: res => { resolve(res) }, fail: err => { reject(err) } }) }) }
直接把若依生成的api文件复制到项目的api文件夹就可以
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。