<template>
  <div class="app-content">
    <transition :name="transitionName" mode="out-in">
      <router-view />
    </transition>
  </div>
</template>

<script>
export default {
  name: "wContent",
  data() {
    return {
      transitionName: "fade-transform"
    };
  }
  // watch: {//使用watch 监听$router的变化
  //     $route (to, from) {
  //         //如果to索引大于from索引,判断为前进状态,反之则为后退状态
  //         if (to.meta.index > from.meta.index) {
  //             //设置动画名称
  //             this.transitionName = 'slide-left';
  //         } else {
  //             this.transitionName = 'slide-right';
  //         }
  //     }
  // }
};
</script>

<style lang="css" scoped>
.app-content {
  min-width: 1100px;
  min-height: calc(100vh - 10px);
  background-color: white;
  padding: 20px;
  margin: 0 10px 10px;
  border: 1px solid #e9eaec;
  border-radius: 4px;
  box-shadow: 1px 1px 10px 0 rgba(0, 0, 0, 0.1),
    -1px -1px 10px 0 rgba(0, 0, 0, 0.1);
}
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all 0.5s;
}
.fade-transform-enter {
  opacity: 0;
  transform: translateX(-30px);
}
.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
</style>