1、在下载lib压缩包
链接如下
https://download.csdn.net/download/IT_iosers/12709095
1、解压lib文件 并放置在微信小程序的根目录下
2、在根目录下创建一个https文件夹
3、在https文件夹下创建 index.js文件和api.js文件
index.js文件
const Fly = require("../lib/fly/wx")
const fly = new Fly()
fly.config.baseURL = 'https://api.zhuishushenqi.com' // 根路径 (根据自己的根路径进行修改)
fly.interceptors.response.use((response) => {
//只将请求结果的data字段返回
return response.data
}
)
module.exports = fly
在api.js文件中写入
const fly = require('./index')
export default {
//在这里放入api
格式为: 函数名(){
return fly.请求(路径)
}
//获取大分类
getCats() {
return fly.get('/cats/lv2/statistics')
},
}