f1
This commit is contained in:
32
src/layouts/PageLayout.vue
Normal file
32
src/layouts/PageLayout.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div class="from-sky-100/20 to-white bg-gradient-to-b min-h-screen">
|
||||
<van-nav-bar fixed :border="false" placeholder :title="pageTitle" left-arrow @click-left="onClickLeft"
|
||||
z-index="9999" />
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const pageTitle = ref(""); // 用来保存页面标题
|
||||
|
||||
const onClickLeft = () => {
|
||||
// 使用 router 的返回功能
|
||||
router.back();
|
||||
};
|
||||
onMounted(() => { });
|
||||
// 监听路由变化并更新标题
|
||||
watch(
|
||||
() => route.meta.title,
|
||||
(newTitle) => {
|
||||
pageTitle.value = newTitle || "默认标题";
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Reference in New Issue
Block a user