// commpents/mobile-frame/mobile-main.js const app = getApp() Component({ /** * 组件的属性列表 */ options: { multipleSlots: true }, properties: { frameStyle: { type: Object } }, /** * 组件的初始数据 */ data: { infoHeight: '' }, // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖 ready: function () { }, pageLifetimes: { // 组件所在页面的生命周期函数 show: function () { this.searchHeight() }, hide: function () { }, resize: function () { }, }, /** * 组件的方法列表 */ methods: { // 返回上一级 back() { this.triggerEvent('back',) }, tabPath(e) { this.triggerEvent('tabPath', e) }, searchHeight() { let frameStyle = this.properties.frameStyle; let client = app.globalData.client; // 减去状态栏 let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2); // 是否减去底部菜单 if (frameStyle.useBar) infoHeight = infoHeight - 50; if (infoHeight) this.setData({ infoHeight: infoHeight }) } } })