chenjun 3 years ago
parent
commit
e9e788a1f0
1 changed files with 34 additions and 10 deletions
  1. 34 10
      src/layout/components/Sidebar/SidebarItem.vue

+ 34 - 10
src/layout/components/Sidebar/SidebarItem.vue

@@ -1,8 +1,13 @@
 <template>
   <div v-if="!item.hidden">
-    <template v-if="hasOneShowingChild(item.children, item) && !item.alwaysShow">
+    <template
+      v-if="hasOneShowingChild(item.children, item) && !item.alwaysShow"
+    >
       <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
-        <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }">
+        <el-menu-item
+          :index="resolvePath(onlyOneChild.path)"
+          :class="{ 'submenu-title-noDropdown': !isNest }"
+        >
           <!-- <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" /> -->
           <!-- <item :icon="onlyOneChild.meta.title||(item.meta&&item.meta.title)"/> -->
           <!-- <el-tooltip
@@ -14,8 +19,22 @@
           <!-- <img class="nav_item" :src="onlyOneChild.meta.imger" /> -->
           <!-- <span class="pathName" :class="getClass(item.path)"></span>
           </el-tooltip> -->
-          <span class="pathName" v-if="!leup" :class="getClass(item.path)"></span>
-          <span class="pathNamecosy" v-if="leup" :class="getClass(item.path)"></span>
+          <el-tooltip
+            class="item"
+            effect="dark"
+            :content="onlyOneChild.meta.title"
+            placement="right"
+             v-if="!leup"
+            ><span
+              class="pathName"
+              :class="getClass(item.path)"
+            ></span
+          ></el-tooltip>
+          <span
+            class="pathNamecosy"
+            v-if="leup"
+            :class="getClass(item.path)"
+          ></span>
           <span class="pathNameer" v-if="leup">{{
             onlyOneChild.meta.title
           }}</span>
@@ -23,7 +42,12 @@
       </app-link>
     </template>
 
-    <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
+    <el-submenu
+      v-else
+      ref="subMenu"
+      :index="resolvePath(item.path)"
+      popper-append-to-body
+    >
       <template slot="title">
         <img class="nav_item" :src="onlyOneChild.meta.imger" />
       </template>
@@ -64,19 +88,19 @@ export default {
       default: true,
     },
   },
-  data () {
+  data() {
     // To fix https://github.com/PanJiaChen/vue-admin-template/issues/237
     // TODO: refactor with render function
     this.onlyOneChild = null;
     return {};
   },
-  mounted () {
+  mounted() {
     // console.log(this.item, 'item')
     // const vnodes
     // vnodes.push(<span slot='title'>{(title)}</span>)
   },
   methods: {
-    hasOneShowingChild (children = [], parent) {
+    hasOneShowingChild(children = [], parent) {
       // console.log(this.item,'item')
       const showingChildren = children.filter((item) => {
         if (item.hidden) {
@@ -117,7 +141,7 @@ export default {
 
       return false;
     },
-    resolvePath (routePath) {
+    resolvePath(routePath) {
       if (isExternal(routePath)) {
         return routePath;
       }
@@ -126,7 +150,7 @@ export default {
       }
       return path.resolve(this.basePath, routePath);
     },
-    getClass (path) {
+    getClass(path) {
       const p = path.split("/").join("");
       if (p) {
         return p;