vue 路由meta 设置title 导航隐藏

router.js

routes: [{
            path: '/',
            name: 'HelloWorld',
            component: HelloWorld,
            meta: {
                title: "HelloWorld",    要现实的title
                show: true               设置导航隐藏显示
            }

        }]

App.vue

<template>

    <div id="app">

        <router-view></router-view>

        <bottom v-show="this.$route.meta.show"></bottom>   this.$route.meta.show  显示或隐藏

</div> </template>

main.js

1

2

3

4

5

6

7

router.beforeEach((to, from, next) => {

    if (to.meta.title) {

        document.title = to.meta.title

    }

    next()

})<br><br>监听路由 写入 title

 转载:https://www.cnblogs.com/nns4/p/8589539.html

猜你喜欢

转载自blog.csdn.net/qq_38188485/article/details/82146438