当前位置:
首页 >
vue设置页面标题title
发布时间:2023/12/10
38
豆豆
生活随笔
收集整理的这篇文章主要介绍了
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做项