forked from Francis0Cheng/Vue-Personal-Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
34.组件切换-切换动画.html
60 lines (55 loc) · 1.36 KB
/
34.组件切换-切换动画.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./lib/vue.js"></script>
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.v-enter,
.v-leave-to{
transform: translateX(150px);
opacity: 0;
}
.v-enter-active,
.v-leave-active{
transition: all 0.8s ease;
}
</style>
</head>
<body>
<div id="app">
<a href="" @click.prevent="comName='login'">登陆</a>
<a href="" @click.prevent="comName='signup'">注册</a>
<!--通过mode属性,设置组件切换的模式-->
<transition mode='out-in'>
<component :is="comName"></component>
</transition>
</div>
<script>
Vue.component(
'login',
{
template: '<h3>登陆组件</h3>',
}
)
Vue.component(
'signup',
{
template: '<h3>注册组件</h3>'
}
)
var vm = new Vue(
{
el: '#app',
data: {
comName: 'login'
},
methods: {
},
}
)
</script>
</body>
</html>