![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
微信小程序
vueer
菜
展开
-
uni-app网络请求的封装
http.js // 环境的切换 let pubUrl = "" if (process.env.NODE_ENV === 'development') { // 开发环境 pubUrl = "http://192.168.1.101:8888/****" } else if (process.env.NODE_ENV === 'debug') { pubUrl = "" // 调试环境 } else if (process.env.NODE_ENV === 'production') { pubUr原创 2021-04-25 11:21:45 · 1094 阅读 · 0 评论 -
微信小程序的缓存
onLoad: function (options) { //获取缓存 const Cates = wx.getStorageSync('cates') //判断缓存是否存在 if (!Cates) { //不存在,去网络请求 this.apiCategories() } else { //存在判断时间是否超时 if (Date.now() - Cates.time > 1000 * 5) { ..原创 2021-03-29 18:04:01 · 887 阅读 · 0 评论 -
微信小程序网络请求的封装(request)
request的封装,这部分是每次请求的必经之路 http.js const pubUrl = "https://api-hmugo-web.itheima.net/api/public/v1"//这是我要请求的数据接口的公共部分 const http = (options) =>{ return new Promise((resolve,reject) => { wx.request({ url: pubUrl+options.url, method:opt原创 2021-03-29 14:05:32 · 286 阅读 · 0 评论