index.wxml中設(shè)置
<image class="bg" mode="widthFix" src="../../images/invitebg.png"></image>
<view class="customTitle" style="height:{{(globalData.navHeight*2)+4}}rpx">
<image class="bg" mode="widthFix" src="../../images/invitebg1.png"></image>
<image style="top:{{backHeight}}rpx;" src="../../images/left.png" bindtap="back"></image>
<view style="top:{{backHeight}}rpx;">邀請(qǐng)好友</view>
</view>
index.js中
getTopHeight: function () {
//獲取膠囊位置信息
let menuButtonObject = wx.getMenuButtonBoundingClientRect();
//定義導(dǎo)航位置參數(shù)
var globalData = {
navHeight: 0,
navTop: 0,
windowHeight: 0,
ww: 0,
hh: 0,
}
var navTop;
var navHeight;
//獲取手機(jī)系統(tǒng)信息
wx.getSystemInfo({
success: res => {
//導(dǎo)航高度
var statusBarHeight = res.statusBarHeight;
navTop = menuButtonObject.top;
navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2;
globalData.navHeight = navHeight;
globalData.navTop = navTop;
globalData.windowHeight = res.windowHeight;
//可視窗口寬度
var ww = res.windowWidth;
//可視窗口高度
var hh = res.windowHeight;
globalData.ww = ww;
globalData.hh = hh;
// console.log(globalData)
//這是我自定義的返回圖標(biāo)位置高度 21單位是 rpx,是圖標(biāo)高度的一半尼夺,圖標(biāo)高度為48rpx
var backHeight = (navTop * 2 + (navHeight - navTop)) - 30;
this.setData({
globalData: globalData,
backHeight: backHeight
})
},
fail(err) {
console.log(err);
}
})
},
index.json中
{
"navigationBarTitleText": "邀請(qǐng)好友",
"navigationStyle":"custom",
"navigationBarTextStyle": "white",
"usingComponents": {}
}