<template>
  <van-nav-bar v-if="showBackNav" style="height: 45px" :title="title" left-text="返回" left-arrow @click-left="back" @click-right="home">
    <template #right> <van-icon name="home-o" size="18" /><span style="color: #1989fa">首页</span> </template>
  </van-nav-bar>
  <van-nav-bar v-else style="height: 45px" :title="title" @click-right="home">
    <template #right> <van-icon name="home-o" size="18" /><span style="color: #1989fa">首页</span> </template>
  </van-nav-bar>
</template>

<script setup>
import { useRouter } from 'vue-router'

const props = defineProps({
  showBackNav: {
    type: Boolean,
    default: true,
  },
})

const router = useRouter()
const title = router.currentRoute.value.meta.title
const back = () => {
  router.go(-1)
}
const home = () => {
  router.push('/hospitalService')
}
</script>