I Try Do

Vue 页面过渡动画

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<template>
<div id="app">
<transition name="page-toggle-transition">
<router-view class="page-toggle-transition"/>
</transition>
</div>
</template>

<script>
export default {
name: 'App'
}
</script>

<style lang="scss">
#app {
.page {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;

&.page-top-transition {
transition: opacity .3s ease;
&.page-top-transition-enter, &.page-top-transition-leave-to {
opacity: 0;
}
}

&.page-push-transition {
transition: transform .3s ease, opacity .3s ease;
&.page-push-transition-enter {
transform: translateX(100%);
}
&.page-push-transition-leave-to {
opacity: 0;
}
}

&.page-pop-transition {
transition: transform .3s ease, opacity .3s ease;
&.page-pop-transition-enter {
opacity: 0;
}
&.page-pop-transition-leave-to {
transform: translateX(100%);
}
}

&.page-toggle-transition {
transition: transform .3s ease, opacity .3s ease;
&.page-toggle-transition-enter {
transform: translateX(100%);
}
&.page-toggle-transition-leave-to {
transform: translateX(100%);
opacity: 0;
}
}
}
}
</style>