浏览代码

1.router修改:
路由为home下的legendLibrary(图例)时
隐藏menuList

unknown 4 年之前
父节点
当前提交
b65809ba7c
共有 1 个文件被更改,包括 50 次插入27 次删除
  1. 50 27
      src/views/index.vue

+ 50 - 27
src/views/index.vue

@@ -9,35 +9,58 @@
 import menuList from '@/components/menuList.vue'
 
 export default {
-    props: [],
-    data() {
-        return {
-            modelNum: 0,
-            // shebeisheshiShow: false,
-            routerName: 'aa',
-            imgSrcNum: 1,
-            tanchuanShow: false
-        }
+  props: [],
+  data() {
+    return {
+      modelNum: 0,
+      // shebeisheshiShow: false,
+      routerName: "aa",
+      imgSrcNum: 1,
+      tanchuanShow: false,
+      showMenu: true, //是否显隐menuList
+    };
+  },
+  computed: {},
+  created() { },
+  mounted() {
+    //   路由为home下的legendLibrary(图例)时,刷新时执行 handleRoute 路由处理函数
+    this.handleRoute(this.$route);
+  },
+  watch: {
+    // tanchuanShow(newVal) {
+    //   console.log(newVal)
+    // }
+    $route: "handleRoute",
+  },
+  methods: {
+    handlerouterName(val) {
+      console.log(val);
+      this.routerName = val;
+      if (val == "de") {
+        this.modelNum = 3;
+      } else if (val == "floorFunc") {
+        this.modelNum = 2;
+      }
     },
-    computed: {},
-    created() {},
-    mounted() {},
-    watch: {
-        // tanchuanShow(newVal) {
-        //   console.log(newVal)
-        // }
-    },
-    methods: {
-        handlerouterName(val) {
-            console.log(val)
-            this.routerName = val
-            if (val == 'de') {
-                this.modelNum = 3
-            } else if (val == 'floorFunc') {
-                this.modelNum = 2
-            }
-        }
+    /**
+     * @name handleRoute
+     * @param newRoute 当前路由
+     * @description 路由处理函数, 当前路由为home下的legendLibrary(图例)时,隐藏 menuList组件
+     */
+    handleRoute(newRoute) {
+      let path = "";
+      newRoute.path && (path = newRoute.path);
+      if (!path) {
+        return true;
+      }
+      let lastPath = path.split("home/")[1];
+      if (lastPath === "legendLibrary") {
+        this.showMenu = false;
+      } else {
+        this.showMenu = true;
+      }
     },
+  },
     components: {
         menuList
     }