推荐使用vue-wechat-title插件
安装
npm install vue-wechat-title --save
用法
1,在 main.js 中引入
import VueWechatTitle from 'vue-wechat-title'
Vue.use(VueWechatTitle)
2,在路由文件 index.js 中给每个路由添加 title
// 挂载路由
const router = new Router({
mode: 'history',
routes:[
{
path: '/',
name: 'Index',
component: Index,
meta: {
title: '首页' // 标题设置
}
}]
});
3,在 app.vue 中修改 router-view 组件
<router-view v-wechat-title='$route.meta.title'></router-view>
自定义加载的图片地址 默认是 ./favicon.ico 可以是相对或者绝对的
<div v-wechat-title="$route.meta.title" img-set="/static/logo.png"></div>
评论