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)
transition-group呈现一个实际元素:<span>默认情况下为 a。所以span在v-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
我无法获得Jacob Goh的答案,因此我以他的答案为灵感进行了一些调整,并提出了解决方案。
<template>
...
<transition-group name="cards" tag="div" class="layout row wrap">
...
</transition-group>
...
</template>
Run Code Online (Sandbox Code Playgroud)
将过渡组标签设置为div并为其分配适当的类。