store-management-app/src/components/navBar/index.vue

63 lines
1.5 KiB
Vue
Raw Normal View History

2024-09-09 07:35:17 +00:00
<template>
<view>
2024-10-09 07:59:18 +00:00
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
2024-09-09 07:35:17 +00:00
<!-- 建议放在外层 -->
<up-sticky>
2024-10-09 07:57:35 +00:00
<up-navbar @leftClick="backhandle" safeAreaInsetTop :placeholder="true">
2024-09-09 07:35:17 +00:00
<template #left>
<view class="uv-nav-slot">
<uv-icon name="arrow-left" size="19" v-if="isShowLeft"></uv-icon>
</view>
</template>
<template #right>
<slot name="right"></slot>
</template>
<template #center>
<span style="font-size: 34rpx; font-weight: bold">
<slot></slot>
</span>
</template>
</up-navbar>
</up-sticky>
</view>
</template>
<script setup>
2024-10-10 02:37:19 +00:00
import { computed, useSlots, onMounted } from "vue";
2024-09-09 07:35:17 +00:00
const isShowLeft = computed(() => {
const pages = getCurrentPages();
return pages.length === 1 ? false : true;
});
const backhandle = () => {
const pages = getCurrentPages();
if (pages.length === 1) return;
uni.navigateBack();
};
2024-10-09 07:43:03 +00:00
const root = document.documentElement;
root.style.setProperty(
"--statusBarHeight",
2024-10-10 02:37:19 +00:00
`${
plus.storage.getItem("RunTime") === "app"
? plus.navigator.getStatusbarHeight()
: 0
}px`
2024-10-09 07:43:03 +00:00
);
2024-09-09 07:35:17 +00:00
</script>
<style lang="scss" scoped>
.status_bar {
2024-10-09 07:57:35 +00:00
height: var(--status-bar-height);
}
:deep(.u-status-bar) {
2024-10-09 07:43:03 +00:00
margin-top: var(--statusBarHeight);
2024-09-09 07:35:17 +00:00
}
@mixin flex($direction: row) {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: $direction;
}
</style>