小功能(不常用)
//app.js
App({
onLaunch: function (options) {
// 判斷是否由分享進(jìn)入小程序
if (options.query.shareType == 998) {
this.globalData.share = true
} else {
this.globalData.share = false
};
//獲取設(shè)備頂部窗口的高度(不同設(shè)備窗口高度不一樣,根據(jù)這個來設(shè)置自定義導(dǎo)航欄的高度)
//這個最初我是在組件中獲取,但是出現(xiàn)了一個問題,當(dāng)?shù)谝淮芜M(jìn)入小程序時導(dǎo)航欄會把
//頁面內(nèi)容蓋住一部分,當(dāng)打開調(diào)試重新進(jìn)入時就沒有問題,這個問題弄得我是莫名其妙
//雖然最后解決了,但是花費了不少時間
wx.getSystemInfo({
success: (res) => {
this.globalData.height = res.statusBarHeight
}
})
},
globalData: {
share: false, // 分享默認(rèn)為false
height: 0,
},
})
使用
//home.js
Page({
data: {
// 此頁面 頁面內(nèi)容距最頂部的距離
height: app.globalData.height * 2 + 20,
}
})