vue 路由meta 设置导航隐藏与显示

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

router.beforeEach((to, from, next) => {
 
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})<br><br>监听路由 写入 title

猜你喜欢

转载自blog.csdn.net/ZiChen_Jiang/article/details/108184918