// components/navBar.js Component({ /** * 组件的属性列表 */ properties:{ back:{ type:Boolean, value:false }, backTitle:{ type:String, value:'' }, share:{ type:Boolean, value:false }, background:{ type:String, value:'' } }, /** * 组件的初始数据 */ data: { statusBarHeight:0, navBarHeight:44 }, lifetimes:{ attached(){ console.log('1212121212'); const windowInfo = wx.getWindowInfo(); this.setData({ statusBarHeight:windowInfo.statusBarHeight }) } }, /** * 组件的方法列表 */ methods: { back(){ wx.navigateBack(); }, share(){ }, getHeight(){ return this.data.statusBarHeight + this.data.navBarHeight; } } })