1、路由文件 :router/index.js 添加 meta属性配置

import Vue from 'vue'
import Router from 'vue-router'
import index '@/view/index'
import user from '@/view/user'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/index',
name: 'index',
component: index,
meta:{
title:'首页'
}
},
{
path: '/user',
name: 'user',
component: user,
meta:{
title:'个人中心'
}
}
]
})

2、在入口文件 main.js中添加 router.beforeEach 配置 以下代码

 import Vue from 'vue'
import App from './App'
import router from './router'
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
next()
})
new Vue({
el: '#app',
router,
template: '<App/>',
components: {App}
})

完结。

vue开发 - 根据vue-router的meta动态设置html里title标签内容的更多相关文章

  1. vue开发 - 根据vue-router的meta动态设置html里标签的内容

    路由文件 :router/index.js import Vue from 'vue'import Router from 'vue-router'import index '@/view/index ...

  2. 【vue开发】vue导出Excel表格教程&demo

    前端工作量最多的就是需求,需求就是一直在变,比如当前端数据写完之后,需要用Excel把数据下载出来:再比如前端在没有数据库想写些demo玩时,也是很好的选择. 第一步安装依赖包,修改配置 1.装依赖: ...

  3. 动态设置html的title

    使用vue前端框架做,竟然丢弃了很多javascript和html的东西了..动态设置title的方法: 1.使用vue的自定义指令 <div v-title>{{htmltitle}}& ...

  4. 每天一点点之vue框架开发 - 数据渲染-for循环中动态设置页面背景色

    实现方式很简单,在属性前加:,表示绑定 :style="{'background':item.bgColor} 代码样例: <li v-for="item in laber_ ...

  5. [vue开发记录]vue仿ios原生datepicker实现

    先上个效果图 现在只开发了年月,还在优化. 在网上看了一个纯原生js实现实现惯性滚动和回弹的文章  地址:https://www.cnblogs.com/ranyonsue/p/8119155.htm ...

  6. 【前端vue开发】vue单页应用添加百度统计

    前言 申请百度统计后,会得到一段JS代码,需要插入到每个网页中去,在Vue.js项目首先想到的可能就是,把统计代码插入到index.html入口文件中,这样就全局插入,每个页面就都有了;这样做就涉及到 ...

  7. 【前端vue开发】vue开发输入姓名,电话,公司表单提交组件

    <template> <div id="parti-info"> <div> <span>您的姓名:</span> &l ...

  8. 【前端vue开发】vue知识点超链接学习笔记

    1.如何去除vue项目中的 # --- History模式: https://www.cnblogs.com/zhuzhenwei918/p/6892066.html 2.三分钟教你写个Vue组件: ...

  9. 【前端vue开发】vue子调父 $emit (把子组件的数据传给父组件)

    ps:App.vue 父组件 Hello.vue 子组件 <!--App.vue :--> <template> <div id="app"> ...

随机推荐

  1. python-条件判断

    条件判断 计算机之所以能做很多自动化的任务,因为它可以自己做条件判断. 比如,输入用户年龄,根据年龄打印不同的内容,在Python程序中,用if语句实现: age = 20 if age >= ...

  2. SpringBoot application.proerties基本配置

    #设置日志输出路径,日志文件名称,输出日志级别 默认日志文件超过10M会切分成多个文件 最新的日志文件就是设置的日志文件 logging.level.root=INFOlogging.level.or ...

  3. 爬虫技术:数据处理josn和pickle模块

    一:json模块 json模块的作用就是讲json字符串("{"a":1,"b":1}")和python能够识别的字典进行相互转换. imp ...

  4. 阿里云ECS无法通过SSL远程链接问题。

    自己配置的SSL,通过密码,公司的是通过密钥,结果也是一样, 环境:centos7.x 网络: 家里宽带 公司网络 省图书馆wifi 家里宽带,公司网络均可以链接上去, 但唯独省图书馆wifi链接失败 ...

  5. root登录

    ,编辑/etc/lightdm/lightdm.conf: gedit /etc/lightdm/lightdm.conf [Seat:*] autologin-guest=false autolog ...

  6. Codeforces 892E Envy

    问题描述 小Q正在玩一个叠塔的游戏,游戏的目标是叠出尽可能高的塔.在游戏中,一共有n张矩形卡片,其中第i张卡片的 长度为a_i,宽度为b_i.小Q需要把所有卡片按一定顺序叠成一座塔,要求对于任意一个矩 ...

  7. SpringBoot 快速集成 Elastic Job

    一.引入依赖 <dependency> <groupId>com.github.kuhn-he</groupId> <artifactId>elasti ...

  8. linux运维、架构之路-MySQL主从复制

    一.MySQL主从复制原理图  MySQL主从复制原理:实现主从复制原理是三个线程完成的,主的I/O线程,备的I/O线程与SQL线程 1.首先主库db01需要开启binlog.授权一个replicat ...

  9. delegate operator (C# reference) and => operator (C# reference)

    The delegate operator creates an anonymous method that can be converted to a delegate type: C#CopyRu ...

  10. window.frames[iframe].document 在ie可以用,在360、火狐中都不兼容?

    <iframe id="myf" scrolling="auto" frameborder="0" src="" ...