Files
2026-02-07 23:14:57 +08:00

51 lines
942 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
})
}
}
})