vue 设置头文件


vue的头文件是在index.html文件中设置的,毕竟vue的入口

先说一下标签页的名字:

就是这个名字的设置,要想每个标签页的名字都不一样,需要做以下这三步:
1. 首先,在index.html文件的head标签里加上title标签, 内容我们用变量来表示

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title>{{title}}</title>

</head>

2. 在index.js文件里,也就是路由文件里,在你写的路由里面,加上title项:

path: '/console/front/privilege',
component: resolve => require(['../components/common/Home.vue'], resolve),
meta: {title: '特权'},  # 这样

3. 在main.js里,用到以前说过的beforeEach钩子函数,写一个判断,来替换index.html里的这个title变量

if(to.meta.title){
   document.title = to.meta.title
  }

再来说一下这个logo,

就在index.html里面加上这个link标签就行了,href写你本地的文件路径,或者一个网络地址

  <link rel="icon" type="image/ico" href="/static/img/favicon-32.ico" />



原文地址:https://www.cnblogs.com/zhang-can/p/9149498.html