Vue + Vuetify 扩展面板 enter/leave 动画

Vue + Vuetify expansion panel enter/leave animation

我目前正在 Vue.js 在 Vuetify 的帮助下开发一个网络应用程序。

我发现扩展面板元素非常有用,我想在我的网站中使用它。

所以我很容易从 Firebase 获取我想要显示的数据,然后我继续使用此模板加载项目:

    <v-expansion-panel popout>
      <v-expansion-panel-content
      v-for="doc in filteredclienti"
      :key="doc.id">
        <div slot="header">{{doc.data().Nome}} {{doc.data().Cognome}}</div>
        <v-card>
        Card content
        </v-card>
     </v-expansion-panel-content>
   </v-expansion-panel

一切正常,面板正常,弹出动画也正常。

现在我想为每个项目显示一个简单的 enter/leave 动画。

我试图在 <v-expansion-panel popuot> 之后添加一个 <transition-group> 标签,但控制台告诉我只需要一个 <v-expansion-panel-content> 元素。

所以我尝试在 <v-expansion-panel-content> 中添加 <transition-group> 但在这种情况下布局不再正确并且弹出动画不再起作用。

我该怎么做?谢谢!

这应该可以解决问题,我添加了一个删除按钮,可以将 "deleted" 文档滑出。 享受。

<template>
  <v-app>
    <v-expansion-panel popout>
      <transition-group name="list" tag="v-expansion-panel">
        <v-expansion-panel-content v-for="doc in filteredclienti" :key="doc.id">
          <div slot="header">
            <span>{{doc.data}}</span>
            <v-btn class="error" @click="deleteItem(doc.id)">
              <v-icon>delete</v-icon>
            </v-btn>
          </div>
          <v-card>Card content</v-card>
        </v-expansion-panel-content>
      </transition-group>
    </v-expansion-panel>
  </v-app>
</template>

<script>
export default {
  data: () => ({
    filteredclienti: [
      { id: 1, data: "data1" },
      { id: 2, data: "data1" },
      { id: 3, data: "data1" },
      { id: 4, data: "data1" }
    ]
  }),
  methods: {
    deleteItem(id) {
      this.filteredclienti = this.filteredclienti.filter(d => d.id !== id);
    }
  }
};
</script>

<style>
.list-enter-active,
.list-leave-active {
  transition: all 1s;
}
.list-enter,
.list-leave-to {
  opacity: 0;
  transform: translateX(100vw);
}
</style>