代码之家  ›  专栏  ›  技术社区  ›  L. Gangemi

Vue+Vuetify扩展面板输入/离开动画

  •  5
  • L. Gangemi  · 技术社区  · 7 年前

    我目前正在Vue中开发一个webapp。在Vuetify的帮助下使用js。

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

    因此,我可以很容易地从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
    

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

    现在,我想为每个项目显示一个简单的进入/离开动画。

    我试图添加 <transition-group> 标记在 <v-expansion-panel popuot> 但控制台告诉我只需要 <v-expansion-panel-content> 要素

    所以我试着添加 <过渡组(>); 在…内 <v-扩展面板-内容(&T); 但在这种情况下,布局不再正确,弹出式动画不再工作。

    我该怎么做?谢谢

    1 回复  |  直到 7 年前
        1
  •  2
  •   Yaniv Peretz    6 年前

    我添加了一个删除按钮,可以将“已删除”的文档滑出。 享受

    <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>