xsh 4 years ago
parent
commit
cecb130188
2 changed files with 19 additions and 7 deletions
  1. 15 5
      src/router/childrenRouters.js
  2. 4 2
      src/views/MainLayout.vue

+ 15 - 5
src/router/childrenRouters.js

@@ -1,3 +1,4 @@
+
 const childrenRouters = [
   /* 牧场概况 */
   {
@@ -6,6 +7,8 @@ const childrenRouters = [
     component: () => import('../views/pastureData/Home.vue'),
     meta: {
       title: '牧场概况',
+      defaultUrl: true,
+      id: 1,
     }
   },
   {
@@ -13,7 +16,8 @@ const childrenRouters = [
     name: 'band',
     component: () => import('../views/pastureData/hand.vue'),
     meta: {
-      title: '存栏走势'
+      title: '存栏走势',
+      defaultUrl: false,
     }
   },
   {
@@ -21,7 +25,8 @@ const childrenRouters = [
     name: 'dayData',
     component: () => import('../views/pastureData/dayData.vue'),
     meta: {
-      title: '每日数据'
+      title: '每日数据',
+      defaultUrl: false,
     }
   },
   {
@@ -29,7 +34,8 @@ const childrenRouters = [
     name: 'dataDetail',
     component: () => import('../views/pastureData/dataDetail.vue'),
     meta: {
-      title: '数据详情'
+      title: '数据详情',
+      defaultUrl: false,
     }
   },
   {
@@ -37,7 +43,9 @@ const childrenRouters = [
     name: 'collectData',
     component: () => import('../views/collectData/collectData.vue'),
     meta: {
-      title: '汇总数据'
+      title: '数据分析',
+      defaultUrl: true,
+      id: 2,
     }
   },
   {
@@ -45,7 +53,9 @@ const childrenRouters = [
     name: 'deviceAdmin',
     component: () => import('../views/deviceAdmin/deviceAdmin.vue'),
     meta: {
-      title: '设备管理'
+      title: '设备管理',
+      defaultUrl: true,
+      id: 3,
     }
   }
 ]

+ 4 - 2
src/views/MainLayout.vue

@@ -119,9 +119,11 @@ export default {
     }
   },
   mounted() {
-    console.log(this.$route);
     this.title = this.$route.meta.title;
-    this.defaultUrl = this.$route.path;
+    if(this.$route.meta.defaultUrl) {
+      this.defaultUrl = this.$route.path;
+      this.navIndex = this.$route.meta.id;
+    }
   }
 }
 </script>