Files
mini-yu/uni_modules/tdesign-uniapp/components/mixins/using-custom-navbar.js
lingxiao865 c5af079d8c first commit
2026-02-10 08:05:03 +08:00

39 lines
887 B
JavaScript

import { systemInfo } from '../common/utils';
const useCustomNavbarBehavior = {
data() {
return {
distanceTop: 0,
};
},
props: {
usingCustomNavbar: {
type: Boolean,
default: false,
},
customNavbarHeight: {
type: Number,
default: 0,
},
},
created() {
if (this.usingCustomNavbar) {
this.calculateCustomNavbarDistanceTop();
}
},
methods: {
calculateCustomNavbarDistanceTop() {
const { statusBarHeight } = systemInfo;
let distance = 0;
// #ifndef H5
// #ifndef APP-PLUS
const menuButton = uni.getMenuButtonBoundingClientRect();
distance = menuButton.top + menuButton.bottom - statusBarHeight;
// #endif
// #endif
this.distanceTop = Math.max(distance, this.customNavbarHeight + statusBarHeight);
},
},
};
export default useCustomNavbarBehavior;