1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > vue设置页面标题title

vue设置页面标题title

时间:2019-09-13 20:42:49

相关推荐

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 router

main.js

import router from './router'router.beforeEach((to, from, next) => {/* 路由发生变化修改页面title */if (to.meta.title) {document.title = to.meta.title}next()})

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。