6 vue-element.ui 左側導航欄


<template>
  <div>
    <el-menu
      :default-active="'/'+activeIndex2"
      mode="vertical"
      background-color="#344a5f"
      text-color="#fff"
      active-text-color="#f56c6c"
      router
      unique-opened
    >
      <el-submenu v-for="item in sideData" :key="item.title" :index="item.title"> 
        <template slot="title">{{item.title}}</template>
        <template v-if="item.subItem">
          <el-menu-item
            v-for="(itemY, index) in item.subItem"
            :key="index"
            :index="itemY.routerpath"  //menu-item 的index才是真正路由導航的作用
          >{{itemY.name}}</el-menu-item>
        </template>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  name: "CompConsoleAside",
  data() {
    return {
      activeIndex2: "infoIndex",
      sideData: [
        {
          title: "控制台",
          subItem: [
            { routerpath: "/2-1", name: "工作1" },
            { routerpath: "/2-2", name: "工作2" },
            { routerpath: "/2-3", name: "工作3" }
          ]
        },
        {
          title: "信息管理",
          subItem: [
            { routerpath: "/infoIndex", name: "信息列表" },
            { routerpath: "/infoCategory", name: "信息分類" },
            { routerpath: "/infoDetailed", name: "信息詳情" }
          ]
        },
        {
          title: "用戶管理",
          subItem: [{ routerpath: "/userIndex", name: "用戶列表" }]
        }
      ]
    };
  },
  methods: {
   
  }
};
</script>



<style lang="scss" scoped>
.el-menu {
  border-right: none;
}
</style>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM