国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

vue 路由meta 設(shè)置導(dǎo)航隱藏與顯示功能的示例代碼

瀏覽:152日期:2022-11-29 13:04:49

vue 路由meta 設(shè)置title 導(dǎo)航隱藏,具體代碼如下所示:

router.js

routes: [{ path: ’/’, name: ’HelloWorld’, component: HelloWorld, meta: {title: 'HelloWorld', 要現(xiàn)實(shí)的titleshow: true設(shè)置導(dǎo)航隱藏顯示 } }]

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>監(jiān)聽路由 寫入 title

PS:vue 中路由meta

meta字段(元數(shù)據(jù))

直接在路由配置的時候,給每個路由添加一個自定義的meta對象,在meta對象中可以設(shè)置一些狀態(tài),來進(jìn)行一些操作。用它來做登錄校驗(yàn)再合適不過了

{ path: ’/actile’, name: ’Actile’, component: Actile, meta: { login_require: false },},{ path: ’/goodslist’, name: ’goodslist’, component: Goodslist, meta: { login_require: true }, children:[ { path: ’online’, component: GoodslistOnline } ]}

這里我們只需要判斷item下面的meta對象中的login_require是不是true,就可以做一些限制了

router.beforeEach((to, from, next) => { if (to.matched.some(function (item) { return item.meta.login_require })) { next(’/login’) } else next()})

總結(jié)

到此這篇關(guān)于vue 路由meta 設(shè)置導(dǎo)航隱藏與顯示功能的示例代碼的文章就介紹到這了,更多相關(guān)vue 路由meta 設(shè)置導(dǎo)航隱藏與顯示內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 盐城市| 耒阳市| 宕昌县| 尼勒克县| 台南县| 天祝| 贵德县| 阆中市| 遂昌县| 宿州市| 德庆县| 通辽市| 黄平县| 耒阳市| 宁德市| 宝兴县| 土默特左旗| 北安市| 花莲县| 遂川县| 迁安市| 密山市| 德阳市| 怀来县| 利川市| 嘉鱼县| 西青区| 东台市| 延津县| 景德镇市| 宜良县| 汉阴县| 丰顺县| 滕州市| 巴彦淖尔市| 青冈县| 保亭| 葫芦岛市| 永新县| 华蓥市| 徐水县|