• vue transition切换效果


    <template>
      <div id="app">
        <transition :name="transitionName">
          <keep-alive :exclude="excludeList">
            <router-view/>
          </keep-alive>
        </transition>
          <div class="loading-pop" v-if="loading">
              <loading v-show="loading"/>
          </div>
      </div>
    </template>
    <script>
    import { mapState, mapMutations } from 'vuex'
    // import { toShare } from './utils/wxshare'
    import loading from './components/tkloading'
    export default {
        name: 'App',
        computed: {
            ...mapState(['loading'])
        },
        data () {
            return {
                transitionName: '',
                excludeList: ['internalActivityHomePage', 'internalActivityHome', 'homePage', 'Home', 'editTrack', 'editCustomerInformation', 'policyDetail', 'internalActivityQuestion', 'internalCustomerDetail']
            }
        },
        components: {
            loading
        },
        created () {
            console.log('环境', process.env.NODE_ENV)
            // const userInfo = localStorage.getItem('userInfo')
            // if (userInfo && userInfo !== 'undefined') {
            //     this.$store.commit('userInfo', JSON.parse(userInfo))
            // }
            // toShare({})
            // console.log('this.loadingM(false)')
            this.loadingM(false)
        },
        methods: {
            ...mapMutations({ loadingM: 'loading' })
        },
        watch: {
            $route (to, from) {
                if (to.meta.index > from.meta.index) {
                    this.transitionName = 'slide-left'
                } else {
                    this.transitionName = 'slide-right'
                }
            }
        }
    }
    </script>
    
    <style lang="less">
      body{
        max- 750px;
        margin: 0 auto;
        font-size: 14px;
        background: #F5F5F5;
        color: #333;
      }
      #app {
        max- 750px;
        margin:0 auto;
      }
      #nav {
        padding: 30px;
    
        a {
          font-weight: bold;
          color: #2c3e50;
          &.router-link-exact-active {
            color: #42b983;
          }
        }
      }
      .slide-left-enter {
          transform: translateX(100%);
      }
    
      .slide-right-enter {
          transform: translateX(-100%);
      }
    
      .slide-left-enter-active,
      .slide-right-enter-active {
          position: relative;
          z-index: 999;
          transition: all 0.4s;
      }
    
      .slide-left-leave-active,
      .slide-right-leave-active {
          position: relative;
          z-index: -1;
      }
      .loading-pop {
          position: absolute;
          top: 0;
          left: 0;
           100%;
          height: 150vh;
          padding-top: 40vh;
          box-sizing: border-box;
          background-color: rgba(0, 0, 0, 0.2);
          display: flex;
          justify-content: center;
          flex-direction: column;
          align-items: center;
          z-index: 100;
      }
    </style>
  • 相关阅读:
    1373:鱼塘钓鱼(fishing)
    1261:【例9.5】城市交通路网
    1259:【例9.3】求最长不下降序列
    1260:【例9.4】拦截导弹(Noip1999)
    1258:【例9.2】数字金字塔
    1261:【例9.5】城市交通路网
    1260:【例9.4】拦截导弹(Noip1999)
    1259:【例9.3】求最长不下降序列
    1257:Knight Moves
    [HAOI2008]硬币购物(动态规划、容斥、搜索)
  • 原文地址:https://www.cnblogs.com/javascript9527/p/16086497.html
Copyright © 2020-2023  润新知