亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Vue3實現簡約型側邊欄的示例代碼

瀏覽:3日期:2022-06-13 15:13:51
目錄1、首先配置好路由地址2、然后實現頁面入口3、然后實現AAAAAA和BBBBBB頁面

有時遇到一些需求,需要實現左邊側邊欄為父級菜單,右側內容區的頂部為子級菜單,以及其底部為子級菜單對應的模塊內容。

如此,簡單實現如下:

1、首先配置好路由地址

【如:/src/router/index.ts】

import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'const routes: Array<RouteRecordRaw> = [ { path: '/', redirect: '/xxxxxx' }, { path: '/xxxxxx', name: '帥龍之龍', component: () => import('@/views/XXXXXX/index.vue'), children: [ {path: '/xxxxxx/aaaaaa',name: '赤龍神帝',components: { AAAAAA: () => import('@/views/XXXXXX/AAAAAA/index.vue') },children: [] }, {path: '/xxxxxx/bbbbbb',name: '待定欄目',components: { BBBBBB: () => import('@/views/XXXXXX/BBBBBB/index.vue') },children: [], }, ] }]const router = createRouter({ history: createWebHashHistory(), routes})export default router2、然后實現頁面入口

【如:/src/views/XXXXXX/index.vue】

<template> <div class='index-page'> <div class='index-page-navbar'> <div :class='activePage == 'AAAAAA' ? 'index-page-navbar-active' : ''' @click='handleNavbarItemClick('AAAAAA')'><span>赤龍神帝</span> </div> <div :class='activePage == 'BBBBBB' ? 'index-page-navbar-active' : ''' @click='handleNavbarItemClick('BBBBBB')'><span>待定欄目</span> </div> </div> <div class='index-page-content'> <router-view name='AAAAAA' v-if='activePage == 'AAAAAA'' /> <router-view name='BBBBBB' v-if='activePage == 'BBBBBB'' /> </div> </div></template><script>export default { data () { return { // 當前激活的頁面 activePage: '', } }, watch: { }, created() { this.init() }, mounted() { // 設置頁面標題 document.title = '帥龍之龍' }, methods: { /** * 獲取初始化參數 */ async init() { this.activePage = 'AAAAAA' const query = this.$route.query this.handleMatchRouter(this.activePage) }, /** * 激活頁面句柄 */ handleActivePageChange(activePage) { // 點擊 el-tab 頁面時,將 this.$route.query 置為 {} this.$route.query = {} this.handleMatchRouter(activePage) }, /** * 激活頁面句柄 */ handleMatchRouter(activePage) { const path = this.$route.path const b = path.toLowerCase().includes(activePage.toLowerCase()) if (activePage == 'AAAAAA') {if (!b) { this.$router.push({ path: '/xxxxxx/aaaaaa', query: this.$route.query, }) } } else if (activePage == 'BBBBBB') {if (!b) { this.$router.push({ path: '/xxxxxx/bbbbbb', query: this.$route.query, })} } }, /** * 點擊側邊導航欄 */ handleNavbarItemClick(item) { this.activePage = item this.$route.query = {} this.handleMatchRouter(item) }, }}</script><style lang='less' scoped> .index-page { display: flex; flex-direction: row; width: 100%; height: 100%; position: relative; background-color: #fff; .index-page-navbar { flex: none; width: 40px; height: 100%; border-right: 1px solid #dfe1e6; .index-page-navbar-item {display: grid;width: 100%;height: 150px;background-color: #fff;border-bottom: 1px solid #dfe1e6;writing-mode: tb-rl;text-align: center;align-items: center;user-select: none;cursor: pointer;transition: all ease 0.3s;span { color: #303133; font-size: 14px; letter-spacing: 1.5px;} } .index-page-navbar-active {background-color: #5e7ce0;span { color: #fff;} } } .index-page-content { flex: 1; position: relative; height: 100%; margin: 0; padding: 0; overflow: hidden; } }</style>3、然后實現AAAAAA和BBBBBB頁面

【如:/src/views/XXXXXX/AAAAAA/index.vue /src/views/XXXXXX/BBBBBB/index.vue】

<template> <div style='width: 100%; height: 100%; display: grid; align-items: center; text-align: center'> <span style='color: #303133; font-size: 14px;'>HelloWorld!...</span> </div></template>

4、效果如下:~

到此這篇關于Vue3實現簡約型側邊欄的示例代碼的文章就介紹到這了,更多相關Vue3 側邊欄內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 亚洲高清国产品国语在线观看 | 91福利国产在线在线播放 | 成人网mm视频在线观看 | 夜夜夜爽bbbb性视频 | 欧美亚洲中日韩中文字幕在线 | 婷婷综合国产激情在线 | 亚洲第一区精品日韩在线播放 | 日韩专区亚洲国产精品 | 国产91在线免费观看 | 国产一级毛片外aaaa | 综合久久久久综合体桃花网 | 看一级毛片免费观看视频 | 日本成人一区二区 | 一区二区三区免费在线观看 | 国产日韩一区二区三区在线观看 | 美女翘臀白浆直流视频 | 精品一区二区久久久久久久网站 | 国产国产成人精品久久 | 中文字幕一区二区三区免费看 | 九九热网 | 免费一级毛片不卡不收费 | 青草视频在线观看免费 | 亚洲综合站| 国产的一级毛片完整 | 1769国内精品视频在线观看 | 国产精品无码久久综合网 | 亚洲操片 | 国产小视频在线观看 | 羞羞答答www网址进入在线观看 | 在线视频自拍 | 一97日本道伊人久久综合影院 | 国产欧美在线观看 | 国产成人精品综合在线 | 久热99这里只有精品视频6 | 国产日韩亚洲 | 一区欧美| 手机看片1024欧美一级 | 哪个网站能看毛片 | 中文字幕欧美日韩在线不卡 | 大尺度一级毛片波多野结衣 | 精品福利一区二区三区 |