vue 动态修改页面标题title
2019-05-15 10:31
274 查看
vue 动态修改页面标题title
1.安装
npm install vue-wechat-title --save 或 npm install vue-wechat-title -S
2.使用
在main.js中引用插件
import VueWechatTitle from 'vue-wechat-title' Vue.use(VueWechatTitle)
3.在路由router文件 index.js 中给每个路由添加 title
export default new Router({ routes: [ { path: '/', name: 'home', component: Home, meta: { title: ' 首页' // 标题设置 } }, { path: '/about', name: 'about', component: About, meta: { title: ' |关于' // 标题设置 } }, { path: '/case', name: 'case', component: Case, meta: { title: ' 案例' // 标题设置 } }, { path: '/contact', name: 'contact', component: Contact, meta: { title: '联系我们' // 标题设置 } }, { path: '/join', name: 'join', component: Join, meta: { title: ' 加入我们' // 标题设置 } }, { path: '/services', name: 'services', component: Services, meta: { title: ' 服务介绍' // 标题设置 } }, ] })
4,最后一步,在 app.vue 中修改 router-view 组件
//将app.vue 中 <router-view/> // 改为 <router-view v-wechat-title='$route.meta.title'></router-view>
重启刷新页面就ok了
相关文章推荐
- 基于Vue的SPA动态修改页面title的方法
- 微信小程序动态修改页面标题setNavigationBarTitle
- 点击文章,动态改变页面的标题为当前文章的标题〔title〕
- ASP.NET 2.0中动态修改页面标题
- 关于修改掉博客页面标题文字--浏览器上面的标题Title的记录
- Jquery修改页面标题title其它JS失效的解决方法
- ASP.NET 2.0中动态修改页面标题
- 动态修改页面标题,关键字及描述等信息
- asp.net 2.0中动态修改页面标题
- 动态修改页面标题,关键字及描述等信息
- Vue中动态设置页面title
- asp.net 2.0中动态修改页面标题
- js动态修改页面标题
- c#2.0中动态修改页面标题
- javascript修改浏览器title方法 JS动态修改浏览器标题
- asp.net 2.0中动态修改页面标题
- asp.net 2.0中动态修改页面标题
- vue-router动态设置页面title的实例讲解
- asp.net 2.0中动态修改页面标题
- vue项目动态设置页面title及是否缓存页面的问题