Vue3的过渡&动画

2022/8/4 Vue3的过渡&动画vue3

Vue3的过渡&动画

# Vue3基本的过渡

<template>
  <div>
    <button @click="isShow = !isShow">显示&隐藏</button>
    <transition name="why">
      <div v-if="isShow">您好!</div>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: true,
    };
  },
};
</script>
<style lang="scss" scoped>
.why-enter-from,
.why-leave-to {
  opacity: 0;
}
.why-enter-to,
.why-leave-from {
  opacity: 1;
}
.why-enter-active,
.why-leave-active {
  transition: all 0.3s;
}
</style>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33