Commit 44ac2c4e by qinjianhui

feat: 标题栏跟随页面变化

parent e9ba7df6
...@@ -7,6 +7,13 @@ import './styles/index.scss' ...@@ -7,6 +7,13 @@ import './styles/index.scss'
Vue.config.productionTip = false Vue.config.productionTip = false
const title = document.title
router.afterEach((to) => {
if (to.meta?.title) {
document.title = `${to.meta.title} - ${title}`
}
})
new Vue({ new Vue({
router, router,
store, store,
......
...@@ -12,6 +12,9 @@ import ContactPage from '@/views/Home/ContactPage.vue' ...@@ -12,6 +12,9 @@ import ContactPage from '@/views/Home/ContactPage.vue'
Vue.use(VueRouter) Vue.use(VueRouter)
/**
* @type {import('vue-router').RouteConfig}
*/
const routes = [ const routes = [
{ {
path: '/', path: '/',
...@@ -21,41 +24,49 @@ const routes = [ ...@@ -21,41 +24,49 @@ const routes = [
path: '/', path: '/',
name: 'IndexPage', name: 'IndexPage',
component: IndexPage, component: IndexPage,
meta: { title: '首页' },
}, },
{ {
path: '/about', path: '/about',
name: 'AboutPage', name: 'AboutPage',
component: AboutPage, component: AboutPage,
meta: { title: '关于晶闪' },
}, },
{ {
path: '/colorful', path: '/colorful',
name: 'ColorfulPage', name: 'ColorfulPage',
component: ColorfulPage, component: ColorfulPage,
meta: { title: '多彩晶闪' },
}, },
{ {
path: '/culture', path: '/culture',
name: 'CulturePage', name: 'CulturePage',
component: CulturePage, component: CulturePage,
meta: { title: '企业文化' },
}, },
{ {
path: '/join-us', path: '/join-us',
name: 'JoinUsPage', name: 'JoinUsPage',
component: JoinUsPage, component: JoinUsPage,
meta: { title: '加入我们' },
}, },
{ {
path: '/supplier-apply', path: '/supplier-apply',
name: 'SupplierApplyPage', name: 'SupplierApplyPage',
component: SupplierApplyPage, component: SupplierApplyPage,
meta: { title: '申请加入' },
}, },
{ {
path: '/supplier-report', path: '/supplier-report',
name: 'SupplierReportPage', name: 'SupplierReportPage',
component: SupplierReportPage, component: SupplierReportPage,
meta: { title: '供应商举报信' },
}, },
{ {
path: '/contact', path: '/contact',
name: 'ContactPage', name: 'ContactPage',
component: ContactPage, component: ContactPage,
meta: { title: '联系我们' },
}, },
], ],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment