<template>
  <div id="app">
    <transition :name="$route.meta.transition">
      <keep-alive :include="cachedViews">
        <router-view class="router-view"/>
      </keep-alive>
    </transition>
  </div>
</template>

<script>


  export default {
    data() {
      return {
        query: {},
        version: '1.3.3',
        cachedViews: []
      }
    },
    created () {
      this.versionReload()
    },
    methods: {
      versionReload(){
        let version = this.version          //版本号（每次上线前需要更新下版本号）
        console.log('最新系统版本: ',version)
        console.log('当前系统版本: ',this.version)
        let versionLocal = localStorage.getItem('_version_');
        if(version!=versionLocal){
          localStorage.setItem('_version_',version);
          this.version=versionLocal;
          location.reload();
        }
      }
    },
    watch: {
      $route(to) {
        if (to.meta.keepAlive) {
          this.cachedViews.push(to.name)
        }
      }
    }
  }

</script>
<style>
.instant-enter-active,
.instant-leave-active {
  transition: none !important;
}
.router-view {
  position: absolute;
  width: 100%;
  backface-visibility: hidden;
  contain: content;
}
</style>
