18-组件动态切换方式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./lib/vue.js"></script>
<style>
.v-enter,
.v-leave-to{
transform: translateX(150px);
}
.v-enter-active,
.v-leave-active{
transition: all 1s ease;
}
</style>
</head>
<body>
<div id="app">
<a href="登录" @click.prevent="lname='login'">登录</a>
<a href="注册" @click.prevent="lname='zhuce'">注册</a>
<transition mode="out-in">
<component :is="lname"></component>
</transition>
<!--<component :is="lname"></component>-->
</div>
<script>
var vm = new Vue({
el:'#app',
data:{
lname:'login'
},
methods:{},
components:{
login:{
template:'<div>登录组件</div>'
},
zhuce:{
template:'<div>注册组件</div>'
}
}
})
</script>
</body>
</html>