【问题标题】:Nuxt child transitions not working in some casesNuxt 子转换在某些情况下不起作用
【发布时间】:2022-02-07 23:47:11
【问题描述】:

我有一个带有简单子/孙 2 层嵌套的应用程序,我正在尝试在 nuxt-child(ren) 的两层上进行转换。奇怪的是,过渡在孙子上工作得很好,但由于某种原因,即使它是相同的过渡,对孩子也不起作用。我可以在检查器中检查并验证它是否正确应用了这些类。最终发生的是,它不是平滑过渡 500 毫秒,而是暂停 500 毫秒并呈现子页面。

Here's the simple repo 演示了这个问题。 Here's the code sandbox 已部署的应用程序。

我是这样进行转换的:

模板:

    <transition name="jade" mode="out-in">
      <nuxt-child></nuxt-child>
    </transition>

风格:

.jade-enter-active {
  transition: all .3s ease;
}
.jade-leave-active {
  transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.jade-enter, .jade-leave-to
{
  transform: translateX(10px);
  opacity: 0;
}

【问题讨论】:

    标签: vue.js nuxt.js css-transitions


    【解决方案1】:

    虽然我不完全确定为什么会发生这种情况,但有两种方法可以解决这个问题

    • 在单个页面中使用 transition 属性 (Nuxt Docs)

    /src/index.vue

    export default {
      transition: {
        name: 'jade',
        mode: 'out-in'
      }
    }
    
    • nuxt.config.js 中设置pageTransition,它将全局应用于所有过渡组件(Nuxt Docs)

    /nuxt.config.js

    export default {
      pageTransition: 'jade'
      // or
      pageTransition: {
        name: 'jade',
        mode: 'out-in'
      }
    }
    

    这是我使用transition 属性的Sandbox link

    【讨论】:

      猜你喜欢
      • 2018-11-28
      • 2011-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 2017-06-29
      • 1970-01-01
      相关资源
      最近更新 更多