| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | <template>	<u-navbar :title="title" :bgColor="bgColor" :titleStyle="titleStyle">		<view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">			<u-icon v-if="showback" name="arrow-left" size="44" :color="leftIconColor" @tap="toBack(backUrl)"></u-icon>		</view>	</u-navbar></template><script setup lang="ts">import { ref } from 'vue'// 定义组件属性const props = defineProps({	title: {		type: String,		default: ''	},	showback: {		type: Boolean,		default: true	},	backUrl: {		type: String,		default: ''	},	bgColor: {		type: String,		default: '#ffffff'	},	leftIconColor: {		type: String,		default: '#111111'	},	titleStyle: {		type: Object,		default: () => ({			fontSize: '36rpx',			fontWeight: 'bold',			color: '#111111'		})	},	backAlert: {		type: Boolean,		default: false	}})// 定义组件状态const tabUrls = ref([	'/pages/home',	'/pages/nonprofit',	'/pages/my'])// 导出方法供模板使用const toBack = (url: string) => {	if (props.backAlert) {			} else {		dealBack(url)	}}const dealBack = (url: string) => {	if (!url) {		if (uni.getStorageSync('options')) {			const options = JSON.parse(decodeURIComponent(uni.getStorageSync('options')))			uni.redirectTo(options)			uni.removeStorageSync('options')			return		}		const pages = getCurrentPages()		if (pages && pages.length > 1) {			uni.navigateBack()		} else {			uni.reLaunch({ url: '/pages/home' })		}	} else {		if (tabUrls.value.find(u => u === url)) {			uni.reLaunch({ url })		} else {			uni.redirectTo({ url })		}	}}</script><style lang="scss" scoped>	.u-navbar--fixed {		z-index: 99999 !important;	}</style>
 |