加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vue页面过度效果实现

发布时间:2020-12-16 23:29:25 所属栏目:百科 来源:网络整理
导读:首先在app.vue的标签外加上transition标签 给其设定 进入效果 离开效果 引入animate.css然后在app.vue页面监听路由的变化 watch: { // 监听 $route 为店内页设置不同的过渡效果 $route(to,from) { const toDepth = to.path.length; const fromDepth = from.p

首先在app.vue的标签外加上transition标签 给其设定 进入效果 离开效果 引入animate.css 然后在app.vue页面监听路由的变化

watch: {
    // 监听 $route 为店内页设置不同的过渡效果
    $route(to,from) {
      const toDepth = to.path.length;
      const fromDepth = from.path.length;
      if (toDepth === 2) {
        this.$store.commit("setPageName",to.name);
      }
      //同一级页面无需设置过渡效果
      if (toDepth === fromDepth) {
        return;
      }
      this.enterAnimate =
        toDepth > fromDepth ? "animated fadeInRight" : "animated fadeInLeft";
      this.leaveAnimate =
        toDepth > fromDepth ? "animated fadeOutLeft" : "animated fadeOutRight";
    }
  },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读