Explorar el Código

监听地址变化,主页不选中侧边栏

dujingxian hace 4 años
padre
commit
a5d6b1982d
Se han modificado 1 ficheros con 11 adiciones y 0 borrados
  1. 11 0
      src/pages/index.vue

+ 11 - 0
src/pages/index.vue

@@ -202,6 +202,17 @@ export default {
             });
         },
     },
+    // 监听器
+    watch: {
+        '$route': {
+            handler(newVal) {
+                // console.log(newVal.path, oldVal.path);
+                if (newVal.path === '/') {
+                    this.curPath = ''
+                }
+            }
+        }
+    }
 };
 </script>