简体   繁体   English

VueJS 转换与 Pug 部分

[英]VueJS transitions with Pug partials

I have multiple 'pages' of content in a multi-step process where always one of these pages is shown at a time.我在一个多步骤的过程中有多个“页面”的内容,其中总是一次显示这些页面之一。 I am trying to use VueJS's transition feature to make this content slide in / out like a carousel.我正在尝试使用 VueJS 的过渡功能使此内容像旋转木马一样滑入/滑出。 The contents that are sliding in / out are contained in seperate pug files, which I am including in my parent pug that displays the "carousel".滑入/滑出的内容包含在单独的 pug 文件中,我将这些文件包含在显示“轮播”的父 pug 中。

I had no problem creating this slide in / out effect with regular HTML elements, but it seems like wrapping this transition element around includes of other pug files seems to mess with it somewhat.我使用常规 HTML 元素创建此滑入/滑出效果没有问题,但似乎将此过渡元素包裹在其他 pug 文件的包含中似乎有些混乱。

So my parent pug file looks something like this所以我的父 pug 文件看起来像这样

.
.
.
div.h-100(v-if="initialized")
  transition(name="slide" mode="out-in")
    #page-1.position-relative.h-100(v-show="step === 0")
      include ./_page-1-partial.pug
  transition(name="slide" mode="out-in")
    #page-2.position-relative.h-100(v-show="step === 1")
      include ./_page-2-partial.pug
  transition(name="slide" mode="out-in")
    #page-3.position-relative.h-100(v-show="step === 2")
      include ./_page-3-partial.pug

This is the css for the slide classes这是幻灯片类的 css

  .slide-enter-active, .slide-leave-active {
    transition: all 0.75s ease-in-out;
  }
  .slide-enter {
    transform: translate(150%, 0);
  }

  .slide-enter-to, .slide-leave {
    transform: translate(0, 0);
  }

  .slide-leave-to {
    transform: translate(-150%, 0);
  }

But what ends up happening is if I set up by one step, the current content slides out to the left, but instead of the new content sliding in from the right, it just instantly appears.但最终发生的是,如果我一步一步设置,当前内容向左滑出,但新内容不是从右侧滑入,而是立即出现。

And if I step down by one step, the current content instantly disappears, and the new content slides in from the right.而我再往下走一步,当前内容瞬间消失,新内容从右侧滑入。

Is there something special about including pug partials that I need to consider when trying to work with these sorts of transitions?在尝试处理这些类型的转换时,我需要考虑包含 pug 部分是否有什么特别之处?

I have found my actual problem.我发现了我的实际问题。 The fact that I am including pug partials was not the problem, it was simply that with both partials existing at the same time, one was above the other and pushing it out of view.我包含 pug 部分的事实不是问题,只是因为两个部分同时存在,一个在另一个之上并将其推到视野之外。 I solved this by changing the positions to absolute我通过将位置更改为绝对来解决这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM