Blame view

src/common/Home.vue 1.35 KB
1172ebb79   Adam   auto commit the c...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  <template>
      <div class="wrapper">
          <v-head></v-head>
          <v-sidebar></v-sidebar>
          <div class="content-box" :class="{'content-collapse':collapse}">
              <v-tags></v-tags>
              <div class="content">
                  <transition name="move" mode="out-in">
                      <keep-alive :include="tagsList">
                          <router-view></router-view>
                      </keep-alive>
                  </transition>
                  <el-backtop target=".content"></el-backtop>
              </div>
          </div>
      </div>
  </template>
  
  <script>
  import vHead from './Header.vue';
  import vSidebar from './Sidebar.vue';
  import vTags from './Tags.vue';
  import bus from './bus';
  export default {
      data() {
          return {
              tagsList: [],
              collapse: false
          };
      },
      components: {
          vHead,
          vSidebar,
          vTags
      },
      created() {
          bus.$on('collapse-content', msg => {
              this.collapse = msg;
          });
          // 只有在标签页列表里的页面才使用keep-alive,即关闭标签之后就不保存到内存中了。
          bus.$on('tags', msg => {
              let arr = [];
              for (let i = 0, len = msg.length; i < len; i++) {
                  msg[i].name && arr.push(msg[i].name);
              }
              this.tagsList = arr;
          });
      }
  };
  </script>