onLoad() {
wx.setNavigationBarTitle({
title: `首页`
})
},
复制代码
在appjs的window内加入--- "navigationStyle": "custom"
复制代码
注意:android
wx.getSystemInfo 和 wx.getSystemInfoSync 获取机器信息
screenHeight - windowHeight 计算标题栏高度
标题栏高度:
‘iPhone’: 64,
‘iPhone X’: 88,
‘android’: 68
复制代码
1,写好模块布局样式,引入模块布局样式,便可使用;
wxml引入文件:
@import "/components/swiper/swiper-default.wxml
wxss引入文件:
@import "/components/swiper/swiper-default.wxss";
复制代码
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" })
})
复制代码
onPullDownRefresh:function()
{
wx.showNavigationBarLoading() //在标题栏中显示加载
//模拟加载
setTimeout(function()
{
// complete
wx.hideNavigationBarLoading() //完成中止加载
wx.stopPullDownRefresh() //中止下拉刷新
},1500);
},
复制代码