64 lines
1.1 KiB
Vue
Executable File
64 lines
1.1 KiB
Vue
Executable File
<template>
|
|
<div v-if="false"></div>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapState} from "vuex";
|
|
|
|
export default {
|
|
name: 'PageTitle',
|
|
props: {
|
|
title: {
|
|
type: [String, Number],
|
|
default: ''
|
|
},
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
pagePath: ''
|
|
}
|
|
},
|
|
|
|
activated() {
|
|
this.updateTitle()
|
|
},
|
|
|
|
|
|
computed: {
|
|
...mapState(['userId']),
|
|
},
|
|
|
|
watch: {
|
|
title: {
|
|
handler() {
|
|
this.initTitle()
|
|
},
|
|
immediate: true
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
initTitle() {
|
|
this.pagePath = this.$route.path;
|
|
this.updateTitle()
|
|
},
|
|
|
|
updateTitle() {
|
|
if (this.pagePath == '') {
|
|
return;
|
|
}
|
|
let pageTitle = this.title;
|
|
let {title} = document;
|
|
if (pageTitle !== title && this.pagePath === this.$route.path) {
|
|
this.setPageTile(pageTitle);
|
|
}
|
|
},
|
|
|
|
setPageTile(title) {
|
|
document.title = title;
|
|
}
|
|
}
|
|
}
|
|
</script>
|