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