vue打开新的标签页+动态渲染标题

一 vue打开新的标签页

Hearder.vue(修订)

methods: {
            jumphome(location) {
                localStorage.this_nav = location;
                this.$router.push(location);
            },
            jump(location) {
                // 改变永久仓库的值
                localStorage.this_nav = location;
                // vue-router除了提供router-link标签跳转页面以外,还提供了 js跳转的方式
                // this.$router.push(location);
                window.open(location,'_blank')
            },

二 vue-动态渲染标题

main.js(修订)


...

// 动态修改页面标题
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
});

...


router.js(修订)

...

{
    path: '/',
    name: 'home',
    component: Home,
    meta:{
      title:'vue-❤-yan'
    }

{
    path: '/course',
    name: 'course',
    component: Course,
    meta:{
      title:'实战课'
    }
  },
{
    path: '/Light-Course',
    name: 'Light_Course',
    component: LightCourse,
    meta:{
      title:'轻课'
    }
...