<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../vue.js"></script>
<STYle>
.v-enter,.v-leave-to{
opacity: 0;
transform: translateX(150px);
}
.v-enter-active,.v-leave-active{
transition: all 0.5s ease;
}
</STYle>
</head>
<body>
<!-- 第一种
<div id="app">
<a href="" @click.prevent="flag=true">登录</a>
<a href="" @click.prevent="flag=flase">注册</a>
<login v-if='flag'></login>
<register v-else='flag'></register>
</div>
<script>
Vue.component('login', Vue.extend({
template: '<h3>登录</h3>'
}))
Vue.component('register', Vue.extend({
template: '<h3>注册</h3>'
}))
var vm = new Vue({
el: '#app',
data: {
flag: true
},
methods: {}
})
</script>
-->
<!-- 第二种 -->
<div id="app">
<a href="" @click.prevent="comName='login'">登录</a>
<a href="" @click.prevent="comName='register'">注册</a>
<transition MODE="out-in">
<component :is="comName"></component>
</transition>
</div>
<script>
Vue.component('login', Vue.extend({
template: '<h3>登录</h3>'
}))
Vue.component('register', Vue.extend({
template: '<h3>注册</h3>'
}))
var vm = new Vue({
el: '#app',
data: {
comName: ''
},
methods: {}
})
</script>
</body>
</html>
版权声明:本文为weixin_44870644原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。