vue 路由meta 设置title 导航隐藏

router.js

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

        }]

App.vue

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

  

main.js

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

    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})
监听路由 写入 title