header.vue
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<div class="title_wrap">
<div class="title_dir" v-show="isShowArrow" @click="arrowTo">
<ArrowLeftBold class="title_arrow"/>
</div>
<div class="page_title">{{title}}</div>
<div v-show="false">{{route.path}}</div>
</div>
</template>
<script setup lang="ts">
import { ArrowLeftBold } from '@element-plus/icons-vue'
/*import * as api from "./../interface/login"
import {setToken} from "../utils/auth";
import { loginMain } from '../store/index'
import {storeToRefs} from "pinia";
let loginAct = loginMain()
let { getStoreToken } = storeToRefs(loginAct)*/
const route = useRoute();
let title = ref("");
let isShowArrow = ref(true)
let pathList = reactive(['/','/product','/mine'])
const emit = defineEmits(["arrowTo"]);
watchEffect(() => {
let matched = route.matched.filter(item => item.meta && item.meta.title)
if (matched[0]) {
title = matched[0].meta.title
}
isShowArrow = true
if(pathList.includes(route.path)) {
isShowArrow = false
}
})
let arrowTo = () => {
emit('arrowTo')
}
</script>
<style scoped>
.title_wrap {
position: relative;
}
.title_dir {
position: absolute;
left: 15px;
top: 50%;
transform: translateY(-50%);
font-size: 0;
}
.title_arrow {
width: 20px;
}
.page_title {
text-align: center;
line-height: 50px;
font-weight: bold;
border-bottom: 1px #b6b6b6 solid;
background-color: #ffffff;
}
</style>