uni-app(二)接口请求封装,全局输出api

在项目 main.js 同级创建 utils 文件夹,

utils里创建 config.js文件,存储重要参数

// 获取平台信息 const { system, } = uni.getSystemInfoSync() // 请求服务器环境,xxx 在这里是填充,请自行替换 let baseUrl = ['http://xxx', 'https://xxx'] // 小程序重要参数 uni.config = { platform: system.startsWith("iOS") ? 2 : 1, // IOS为2 安卓为1 imgUrl: "https://xxx", // 图片地址前缀 baseUrl: baseUrl[1], appid: "xxx", // appid }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyzfgf.html