验证v-flex的过渡

Dmi*_*ich 5 transitions vue.js vuetify.js

我正在尝试使用此处的Codepen示例实现过渡,但使用了Vuetify。

我注意到在v-flex组件破坏v-flex订单之前添加过渡标签。在此示例codeandbox中,有两条路线,一条具有过渡,另一条没有过渡。

组件具有以下结构:

<v-container>
  <v-layout row wrap pb-2 pt-2>
  <!-- is transition group -->
  <transition-group name="cards" >
    <v-flex xs3
        v-for="card in items"
        :key="card"
        >
        <v-layout>
          <v-card>
            .....
          </v-card>  
        </v-layout>
      </v-flex>
    </transition-group>
  </v-layout>
</v-container> 
Run Code Online (Sandbox Code Playgroud)

Jac*_*Goh 7

transition-group呈现一个实际元素:<span>默认情况下为 a。所以spanv-layout和之间有一个额外的v-flex。这会导致 flexbox 出现故障。

transition-group必须渲染一些东西。您可以将其设置为 renderv-layout而不是span.

但是transition-group有一个限制。它可以设置tag但不能设置props。因此,对于row wrap pb-2 pt-2,您必须使用 CSS 手动添加它。

改变

<template>
    ...
    <v-layout row wrap pb-2 pt-2>
        <transition-group name="cards">
            ...
        </transition-group>
    </v-layout>
    ...
</template>
Run Code Online (Sandbox Code Playgroud)

<template>
    ...
    <transition-group name="cards" tag="v-layout" class="manual-v-layout">
        ...
    </transition-group>
    ...
</template>


<style>
.manual-v-layout {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  padding-bottom: 8px !important;
  padding-top: 8px !important;
}
</style>
Run Code Online (Sandbox Code Playgroud)

它会起作用。

演示:https : //codesandbox.io/s/z2z5yoopol

  • 没有为我工作,但我提供了一个解决方案。但是,这个答案为我指明了正确的方向。谢谢雅各布 (2认同)

Cra*_*rld 5

我无法获得Jacob Goh的答案,因此我以他的答案为灵感进行了一些调整,并提出了解决方案。

<template>
...
  <transition-group name="cards" tag="div" class="layout row wrap">
    ...
  </transition-group>
...
</template>
Run Code Online (Sandbox Code Playgroud)

将过渡组标签设置为div并为其分配适当的类。