123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <div class="header-menu">
- <ul class="header-menu-list">
- <li class="header-menu-item" v-for="(menu, index) of menus" :key="menu" @click="click(index)" :class="{ active: activeIndex == index }">
- {{ menu.text }}
- <router-link :to="menu.path"></router-link>
- </li>
- </ul>
- <ul class="header-menu-dropdown" :class="{ dropdown: dropdown }">
- <li class="header-menu-dropdown-title" @click="clickMenu()"><i class="fa fa-gear"></i>菜单<i class="fa fa-sort-down down"></i></li>
- <ul class="header-menu-dropdown-list">
- <li class="header-menu-dropdown-item" v-for="(menu, index) of menusDropdown" :key="menu" @click="clickSubMenu(index, menu.code)">
- {{ menu.text }}
- </li>
- </ul>
- </ul>
- <ul class="header-menu-user">
- <li class="header-menu-user-title"><i class="fa fa-user"></i>Administrator</li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- menus: [
- {
- text: "状态监视",
- path: "/",
- isActive: true,
- },
- {
- text: "数据管理",
- path: "/",
- isActive: false,
- },
- {
- text: "统计分析",
- path: "/",
- isActive: false,
- },
- {
- text: "健康管理",
- path: "/",
- isActive: false,
- },
- {
- text: "决策支持",
- path: "/",
- isActive: false,
- },
- {
- text: "知识管理",
- path: "/",
- isActive: false,
- },
- {
- text: "智能报表",
- path: "/",
- isActive: false,
- },
- ],
- activeIndex: 0,
- menusDropdown: [
- {
- text: "子菜单1",
- code: "submenu1",
- },
- {
- text: "子菜单2",
- code: "submenu2",
- },
- {
- text: "子菜单3",
- code: "submenu3",
- },
- ],
- dropdown: false,
- };
- },
- methods: {
- click(index) {
- console.log(index);
- this.activeIndex = index;
- },
- clickSubMenu(index, code) {
- console.log(index, code);
- },
- clickMenu() {
- this.dropdown = !this.dropdown;
- },
- },
- computed: {
- activeClass(data) {
- return data.isActive ? "active" : "";
- },
- },
- };
- </script>
- <style lang="less">
- .header-menu {
- display: flex;
- flex-direction: row;
- width: 100%;
- height: 100%;
- font-size: @fontsize;
- .header-menu-list {
- margin: 0;
- padding: 0;
- list-style: none;
- margin-left: auto;
- display: flex;
- flex-direction: row;
- height: 100%;
- .header-menu-item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 9.259vh;
- height: 100%;
- color: @gray;
- cursor: pointer;
- &.active {
- color: @green;
- position: relative;
- background-image: @greenLinearTop;
- &::after {
- content: "";
- position: absolute;
- width: 100%;
- height: 0.463vh;
- border: 0.093vh solid @green;
- border-top: 0;
- left: 0;
- bottom: 0;
- box-sizing: border-box;
- }
- }
- }
- }
- .header-menu-dropdown {
- width: 11.111vh;
- height: 100%;
- margin: 0;
- padding: 0;
- list-style: none;
- .header-menu-dropdown-title {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- color: @gray;
- cursor: pointer;
- i {
- margin: 0 0.741vh;
- transition: all 0.3s;
- }
- }
- .header-menu-dropdown-list {
- display: none;
- margin: 0;
- padding: 0;
- list-style: none;
- margin-left: auto;
- position: absolute;
- .header-menu-dropdown-item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 11.111vh;
- height: 3.704vh;
- color: @gray;
- cursor: pointer;
- position: relative;
- z-index: 1;
- background-color: fade(@write, 5%);
- &::after {
- content: "";
- position: absolute;
- width: 100%;
- height: 0.463vh;
- border: 0.093vh solid @green;
- border-top: 0;
- left: 0;
- bottom: 0;
- box-sizing: border-box;
- }
- &:hover {
- color: @write;
- background-color: fade(@write, 10%);
- }
- }
- }
- &.dropdown {
- .header-menu-dropdown-title {
- .down {
- transform: rotate(180deg);
- }
- }
- .header-menu-dropdown-list {
- display: flex;
- flex-direction: column;
- }
- }
- }
- .header-menu-user {
- width: 16.667vh;
- height: 100%;
- margin: 0;
- padding: 0;
- list-style: none;
- .header-menu-user-title {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- color: @gray;
- cursor: pointer;
- i {
- margin: 0 0.741vh;
- }
- }
- }
- }
- </style>
|