页面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=", "integrity": "sha1-HuO8mhbsv1EYvjNLsV+cRvgvWCU=",
"dev": true "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": { "watchpack": {
"version": "1.7.5", "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", "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", "stylus-loader": "^3.0.2",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-awesome-swiper": "^2.6.7", "vue-awesome-swiper": "^2.6.7",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"vue-wechat-title": "^2.0.5"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",

View File

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

View File

@ -4,8 +4,10 @@ import Vue from 'vue'
import App from './App' import App from './App'
import router from './router' import router from './router'
import VueAwesomeSwiper from 'vue-awesome-swiper' import VueAwesomeSwiper from 'vue-awesome-swiper'
import VueWechatTitle from 'vue-wechat-title'
import 'swiper/dist/css/swiper.css' import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper) Vue.use(VueAwesomeSwiper)
Vue.use(VueWechatTitle)
import 'styles/reset.css' import 'styles/reset.css'
Vue.config.productionTip = false Vue.config.productionTip = false
@ -16,3 +18,9 @@ new Vue({
components: { App }, components: { App },
template: '<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: '/', path: '/',
name: 'Index', name: 'Index',
component: Index component: Index,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/dynamic', path: '/dynamic',
name: 'Dynamic', name: 'Dynamic',
component: Dynamic component: Dynamic,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/public', path: '/public',
name: 'Public', name: 'Public',
component: Public component: Public,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/serve', path: '/serve',
name: 'Serve', name: 'Serve',
component: Serve component: Serve,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/interaction', path: '/interaction',
name: 'Interaction', name: 'Interaction',
component: Interaction component: Interaction,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/reply', path: '/reply',
name: 'InteractionReply', name: 'InteractionReply',
component: InteractionReply component: InteractionReply,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
{ {
path: '/detail', path: '/detail',
name: 'NewsDetail', name: 'NewsDetail',
component: NewsDetail component: NewsDetail,
meta: {
title: '内蒙古自治区财政厅'
}
}, },
] ]
}) })