Files
YGChatCS/pages/order/components/TopNavBar/index.vue
2025-08-01 11:29:03 +08:00

58 lines
1.1 KiB
Vue

<template>
<view class="top-nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
<view class="nav-content">
<view class="nav-left" @click="goBack">
<uni-icons class="icon-back" type="left" size="20" color="#333">
</uni-icons>
</view>
<view class="nav-center">
<slot name="title">
<text class="nav-title">{{ title }}</text>
</slot>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from "vue";
// Props
const props = defineProps({
title: {
type: String,
default: "",
},
showBack: {
type: Boolean,
default: true,
},
});
// Emits
const emit = defineEmits(["back"]);
// 状态栏高度
const statusBarHeight = ref(0);
// 获取系统信息
onMounted(() => {
const systemInfo = uni.getSystemInfoSync();
statusBarHeight.value = systemInfo.statusBarHeight || 44;
});
// 返回上一页
const goBack = () => {
if (props.showBack) {
emit("back");
uni.navigateBack({
delta: 1,
});
}
};
</script>
<style scoped>
@import "./styles/index.scss";
</style>