mirror of
https://git.beihong.wang/wangbeihong/iot-bedroom-environment-controller.git
synced 2026-04-23 11:43:04 +08:00
51 lines
942 B
JavaScript
51 lines
942 B
JavaScript
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight + 'px'
|
||
Component({
|
||
properties: {
|
||
//背景色
|
||
background: {
|
||
type: String,
|
||
value: 'transparent'
|
||
},
|
||
//是否固定在顶部
|
||
isFixed: {
|
||
type: Boolean,
|
||
value: false
|
||
},
|
||
//z-index值,isFixed为true时生效
|
||
zIndex: {
|
||
type: Number,
|
||
value: 99
|
||
},
|
||
//v2.3.0+
|
||
isOccupy: {
|
||
type: Boolean,
|
||
value: false,
|
||
observer(val) {
|
||
this.getStyle()
|
||
}
|
||
}
|
||
},
|
||
data: {
|
||
statusBarHeight: statusBarHeight,
|
||
style: ''
|
||
},
|
||
lifetimes: {
|
||
attached: function () {
|
||
this.getStyle()
|
||
this.triggerEvent('init', {
|
||
statusBarHeight: statusBarHeight
|
||
})
|
||
}
|
||
},
|
||
methods: {
|
||
getStyle() {
|
||
let style = ''
|
||
if (this.data.isOccupy) {
|
||
style += `height:${this.data.statusBarHeight}px;`
|
||
}
|
||
this.setData({
|
||
style
|
||
})
|
||
}
|
||
}
|
||
}) |