mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
59 lines
1.0 KiB
Vue
Executable File
59 lines
1.0 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()
|
|
},
|
|
|
|
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>
|