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

58 lines
1.3 KiB
Vue
Raw Normal View History

2024-09-09 07:35:17 +00:00
<template>
<view>
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<!-- 建议放在外层 -->
<up-sticky>
<up-navbar
fixed
@leftClick="backhandle"
safeAreaInsetTop
:placeholder="true"
>
<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>
import { computed, useSlots } from "vue";
const slots = useSlots();
console.log(slots);
const isShowLeft = computed(() => {
const pages = getCurrentPages();
return pages.length === 1 ? false : true;
});
const backhandle = () => {
const pages = getCurrentPages();
if (pages.length === 1) return;
uni.navigateBack();
};
</script>
<style lang="scss" scoped>
.status_bar {
height: var(--status-bar-height);
}
@mixin flex($direction: row) {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: $direction;
}
</style>