欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue3實(shí)現(xiàn)簡約型側(cè)邊欄的示例代碼

 更新時(shí)間:2023年07月10日 09:47:39   作者:帥龍之龍  
本文主要介紹了Vue3實(shí)現(xiàn)簡約型側(cè)邊欄的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

有時(shí)遇到一些需求,需要實(shí)現(xiàn)左邊側(cè)邊欄為父級菜單,右側(cè)內(nèi)容區(qū)的頂部為子級菜單,以及其底部為子級菜單對應(yīng)的模塊內(nèi)容。

如此,簡單實(shí)現(xiàn)如下:

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 router

2、然后實(shí)現(xiàn)頁面入口

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

<template>
  <div class="index-page">
    <div class="index-page-navbar">
      <div class="index-page-navbar-item" :class="activePage == 'AAAAAA' ? 'index-page-navbar-active' : ''" @click="handleNavbarItemClick('AAAAAA')">
        <span>赤龍神帝</span>
      </div>
      <div class="index-page-navbar-item" :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 {
      // 當(dāng)前激活的頁面
      activePage: '',
    }
  },
  watch: {
  },
  created() {
    this.init()
  },
  mounted() {
    // 設(shè)置頁面標(biāo)題
    document.title = '帥龍之龍'
  },
  methods: {
    /**
     * 獲取初始化參數(shù)
     */
    async init() {
      this.activePage = 'AAAAAA'
      const query = this.$route.query
      this.handleMatchRouter(this.activePage)
    },
    /**
     * 激活頁面句柄
     */
    handleActivePageChange(activePage) {
      // 點(diǎn)擊 el-tab 頁面時(shí),將 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,
          })
        }
      }
    },
    /**
     * 點(diǎn)擊側(cè)邊導(dǎo)航欄
     */
    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、然后實(shí)現(xiàn)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、效果如下:~

到此這篇關(guān)于Vue3實(shí)現(xiàn)簡約型側(cè)邊欄的示例代碼的文章就介紹到這了,更多相關(guān)Vue3 側(cè)邊欄內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue2.0實(shí)現(xiàn)組件數(shù)據(jù)的雙向綁定問題

    Vue2.0實(shí)現(xiàn)組件數(shù)據(jù)的雙向綁定問題

    這篇文章主要介紹了Vue2.0實(shí)現(xiàn)組件數(shù)據(jù)的雙向綁定問題,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2018-03-03
  • vue如何實(shí)現(xiàn)文件上傳及預(yù)覽

    vue如何實(shí)現(xiàn)文件上傳及預(yù)覽

    這篇文章主要介紹了vue如何實(shí)現(xiàn)文件上傳及預(yù)覽問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • vue 在服務(wù)器端直接修改請求的接口地址

    vue 在服務(wù)器端直接修改請求的接口地址

    這篇文章主要介紹了vue 在服務(wù)器端直接修改請求的接口地址的方法,幫助大家更好的理解和使用vue,感興趣的朋友可以了解下
    2020-12-12
  • vue跳轉(zhuǎn)頁面常用的4種方法與區(qū)別小結(jié)

    vue跳轉(zhuǎn)頁面常用的4種方法與區(qū)別小結(jié)

    這篇文章主要給大家介紹了關(guān)于vue跳轉(zhuǎn)頁面常用的4種方法與區(qū)別,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-03-03
  • 阿望教你用vue寫掃雷小游戲

    阿望教你用vue寫掃雷小游戲

    這篇文章主要介紹了阿望教你用vue寫掃雷小游戲,本文通過實(shí)例代碼效果圖展示的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • vue-element換膚所有主題色和基礎(chǔ)色均可實(shí)現(xiàn)自主配置

    vue-element換膚所有主題色和基礎(chǔ)色均可實(shí)現(xiàn)自主配置

    這篇文章主要介紹了vue-element換膚所有主題色和基礎(chǔ)色均可實(shí)現(xiàn)自主配置,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue:內(nèi)存泄露詳解

    vue:內(nèi)存泄露詳解

    這篇文章主要介紹了一個(gè)Vue的內(nèi)存泄露詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2021-10-10
  • vue.js組件vue-waterfall-easy實(shí)現(xiàn)瀑布流效果

    vue.js組件vue-waterfall-easy實(shí)現(xiàn)瀑布流效果

    這篇文章主要為大家詳細(xì)介紹了vue.js實(shí)現(xiàn)瀑布流之vue-waterfall-easy的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • 關(guān)于Vue中this.$set的正確使用

    關(guān)于Vue中this.$set的正確使用

    我們在項(xiàng)目開發(fā)的過程中,經(jīng)常會遇到這種情況:為data中的某一個(gè)對象添加一個(gè)屬性,我們該如何解決這個(gè)問題呢,下面小編給大家?guī)砹薞ue中this.$set的正確使用,感興趣的朋友跟隨小編一起看看吧
    2022-12-12
  • springboot?vue接口測試前端動(dòng)態(tài)增刪表單功能實(shí)現(xiàn)

    springboot?vue接口測試前端動(dòng)態(tài)增刪表單功能實(shí)現(xiàn)

    這篇文章主要為大家介紹了springboot?vue接口測試前端動(dòng)態(tài)增刪表單功能實(shí)現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05

最新評論