vue设置页面标题title
生活随笔
收集整理的這篇文章主要介紹了
vue设置页面标题title
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
每個(gè)頁(yè)面設(shè)置相同標(biāo)題
index.html
直接修改title標(biāo)簽里面的標(biāo)題
(ps: 這個(gè)html文件中也可以引入一些js文件)
每個(gè)頁(yè)面設(shè)置不同標(biāo)題
router - index.js
const router = new Router({mode: 'history',routes: [{path: '/index',name: 'index',component: Index,meta:{// 頁(yè)面標(biāo)題titletitle: '首頁(yè)'}},{path: '/content',name: 'content',component: Content,meta:{title: '內(nèi)容'}}] }) export default routermain.js
import router from './router' router.beforeEach((to, from, next) => {/* 路由發(fā)生變化修改頁(yè)面title */if (to.meta.title) {document.title = to.meta.title}next() })總結(jié)
以上是生活随笔為你收集整理的vue设置页面标题title的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017年,软件开发全过程,描述得不能再
- 下一篇: vue+Ant design vue做项