瀏覽代碼

improve header background (#1416)

杨奕 8 年之前
父節點
當前提交
0373211131
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      examples/components/header.vue

+ 6 - 4
examples/components/header.vue

@@ -227,9 +227,12 @@
       };
     },
     watch: {
-      '$route.path'() {
-        this.isHome = /^home/.test(this.$route.name);
-        this.headerStyle.backgroundColor = `rgba(32, 160, 255, ${ this.isHome ? '0' : '1' })`;
+      '$route.path': {
+        immediate: true,
+        handler() {
+          this.isHome = /^home/.test(this.$route.name);
+          this.headerStyle.backgroundColor = `rgba(32, 160, 255, ${ this.isHome ? '0' : '1' })`;
+        }
       }
     },
     computed: {
@@ -248,7 +251,6 @@
       }
     },
     mounted() {
-      this.isHome = this.$route.name === 'home';
       function scroll(fn) {
         window.addEventListener('scroll', () => {
           fn();