-
Notifications
You must be signed in to change notification settings - Fork 0
/
27 动态切换组件.html
59 lines (50 loc) · 1.47 KB
/
27 动态切换组件.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>组件Component基本定义和用法</title>
<style>
.v-enter,
.v-leave-to{
opacity: 0;
transform:translateX(150px);
}
.v-enter-active,
.v-leave-active{
transition: all 0.5s ease;
}
</style>
<script src="./js/vue-2.5.21.js"></script>
<script>
window.onload = function () {
var vm = new Vue({
el: "#app",
data: {
componentId:"login"
},
methods: {},
components: {
login: {
template: "<h2>这是login组件</h2>",
},
register:{
template:"<h2>这是register组件</h2>"
}
}
});
}
</script>
</head>
<body>
<div id="app">
<input type="button" value="Login" @click="componentId='login'">
<input type="button" value="Register" @click="componentId='register'">
<hr>
<transition mode="out-in">
<component :is="componentId"></component>
</transition>
</div>
</body>
</html>