|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="nav">
|
|
|
<!-- hover -->
|
|
|
- <el-menu unique-opened menu-trigger="hover" background-color="#007ce2" text-color="#fff" active-text-color="#ffd200" :default-active="activeIndex" mode="horizontal">
|
|
|
+ <el-menu :style="{ width: offsetWidth }" unique-opened menu-trigger="hover" background-color="#007ce2" text-color="#fff" active-text-color="#fea764" :default-active="activeIndex" mode="horizontal">
|
|
|
<div class="menuitem" v-for="(item, index) in menus" :key="index">
|
|
|
<nav-item :items="item" @itemClick="handleSelect"></nav-item>
|
|
|
<div class="xian" v-if="index + 1 !== menus.length"></div>
|
|
@@ -26,11 +26,18 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- activeIndex: '00'
|
|
|
+ activeIndex: '00',
|
|
|
+ offsetWidth: null
|
|
|
};
|
|
|
},
|
|
|
async mounted() {
|
|
|
await this.menusQueryAlls();
|
|
|
+ const dom = document.getElementsByClassName('menuitem');
|
|
|
+ let element = 0;
|
|
|
+ for (let i = 0; i < dom.length; i++) {
|
|
|
+ element += Number(dom[i].offsetWidth + 1);
|
|
|
+ }
|
|
|
+ this.offsetWidth = `${element}px`;
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['menusQueryAlls']),
|
|
@@ -99,12 +106,14 @@ export default {
|
|
|
padding-top: 5px;
|
|
|
margin-top: -5px;
|
|
|
.el-menu {
|
|
|
- width: 70%;
|
|
|
+ // width: 70%;
|
|
|
margin: 0 auto;
|
|
|
- display: flex;
|
|
|
+ // display: flex;
|
|
|
border: none;
|
|
|
.menuitem {
|
|
|
position: relative;
|
|
|
+ float: left;
|
|
|
+ margin: 0 auto;
|
|
|
.xian {
|
|
|
border-right: 1px solid #fff;
|
|
|
position: absolute;
|