页面title

This commit is contained in:
dong_bo0602 2021-03-23 15:12:36 +08:00
parent 2c480f69c4
commit d98e489cc5
5 changed files with 51 additions and 16 deletions

5
package-lock.json generated
View File

@ -10883,6 +10883,11 @@
"integrity": "sha1-HuO8mhbsv1EYvjNLsV+cRvgvWCU=",
"dev": true
},
"vue-wechat-title": {
"version": "2.0.5",
"resolved": "https://registry.npm.taobao.org/vue-wechat-title/download/vue-wechat-title-2.0.5.tgz",
"integrity": "sha1-Yo3UvtyhDvObmpj2fKVkpNt3Jgs="
},
"watchpack": {
"version": "1.7.5",
"resolved": "https://registry.npm.taobao.org/watchpack/download/watchpack-1.7.5.tgz?cache=0&sync_timestamp=1612715822561&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwatchpack%2Fdownload%2Fwatchpack-1.7.5.tgz",

View File

@ -16,7 +16,8 @@
"stylus-loader": "^3.0.2",
"vue": "^2.5.2",
"vue-awesome-swiper": "^2.6.7",
"vue-router": "^3.0.1"
"vue-router": "^3.0.1",
"vue-wechat-title": "^2.0.5"
},
"devDependencies": {
"autoprefixer": "^7.1.2",

View File

@ -1,6 +1,6 @@
<template>
<div id="app">
<router-view/>
<router-view v-wechat-title="$route.meta.title"/>
</div>
</template>

View File

@ -4,8 +4,10 @@ import Vue from 'vue'
import App from './App'
import router from './router'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import VueWechatTitle from 'vue-wechat-title'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
Vue.use(VueWechatTitle)
import 'styles/reset.css'
Vue.config.productionTip = false
@ -16,3 +18,9 @@ new Vue({
components: { App },
template: '<App/>'
})
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
next()
})

View File

@ -14,37 +14,58 @@ export default new Router({
{
path: '/',
name: 'Index',
component: Index
},
component: Index,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/dynamic',
name: 'Dynamic',
component: Dynamic
},
component: Dynamic,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/public',
name: 'Public',
component: Public
},
component: Public,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/serve',
name: 'Serve',
component: Serve
},
component: Serve,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/interaction',
name: 'Interaction',
component: Interaction
},
component: Interaction,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/reply',
name: 'InteractionReply',
component: InteractionReply
},
component: InteractionReply,
meta: {
title: '内蒙古自治区财政厅'
}
},
{
path: '/detail',
name: 'NewsDetail',
component: NewsDetail
},
component: NewsDetail,
meta: {
title: '内蒙古自治区财政厅'
}
},
]
})