一.基本小设置
1,设置微信程序导航标题
onLoad() { wx.setNavigationBarTitle({ title: `首页` }) },复制代码
2,微信小程序组件传值
3,微信小程序自定义导航栏
在appjs的window内加入--- "navigationStyle": "custom"复制代码
注意:
wx.getSystemInfo 和 wx.getSystemInfoSync 获取机器信息screenHeight - windowHeight 计算标题栏高度标题栏高度:‘iPhone’: 64,‘iPhone X’: 88,‘android’: 68复制代码
4,微信小程序缓存区别
5,微信小程序import引入模块(wxss/js/wxml)
1,写好模块布局样式,引入模块布局样式,即可使用;wxml引入文件:@import "/components/swiper/swiper-default.wxmlwxss引入文件:@import "/components/swiper/swiper-default.wxss";复制代码
6,封装request;
const $get = (url, data) => { return new Promise((resolve, reject) => { wx.request({ url, data, header: { 'Content-Type': 'json' }, success: resolve, fail: reject }) })}// 使用util.$get(`${movieUrl}/api/v2/article`, { app_id: 6, cid: 4, article_id: this.data.article_id }).then(res => { if (res.data.status === 0) { this.processData(type, res.data.data.articles) }}).catch(e => { this.setData({ isLoading: true, hasMore: false }) wx.stopPullDownRefresh() wx.showToast({ title: `网络错误!`, duration: 1000, icon: "none" })})复制代码
7,小程序下拉刷新;
onPullDownRefresh:function() { wx.showNavigationBarLoading() //在标题栏中显示加载 //模拟加载 setTimeout(function() { // complete wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 },1500); },复制代码