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