Vue动态修改浏览器图标及标题

项目中一般会有需求:浏览器图标为自定义,且浏览器标题的显示是当前所在菜单
这时我们需要通过动态设置浏览器标题,达到该效果。

一、更改浏览器图标

在项目中找到以下文件
在这里插入图片描述
将该文件中的图案更换成想显示的图案

二、动态修改浏览器标题

1.安装插件
npm vue-wechat-title --save
或者
npm install --save vue-wechat-title
如果上述两个命令失败,则根据失败提示安装即可。

2.在main.js里面引入插件
import VueWechatTitle from 'vue-wechat-title' //动态修改浏览器标题
Vue.use(VueWechatTitle)

3.在路由中"meta"中添加/修改title

routes: [{
   path: '/login',
   component: Login,
   meta: {
    title: '登录'
   }
  },
  {
   path: '/homePage',
   component: homePage,
   meta: {
    title: '首页'
   }

4.在App.vue中添加 v-wechat-title
<router-view v-wechat-title='$route.meta.title' />

猜你喜欢

转载自blog.csdn.net/weixin_45489658/article/details/115918426
今日推荐