<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>组件的切换</title>
<style>
a{
text-decoration:none;
font-size: 30px;
color: crimson;
margin:0 20px;
}
input{
background-color: lavenderblush;
margin: 10px 20px;
}
button{
margin: 0 30px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="app">
<a href="#" @click.prevent="flag=true">登录</a>
<a href="#" @click.prevent="flag=false">注册</a>
<!--登录组件-->
<my-com v-if="flag"></my-com>
<!--注册组件-->
<regiter v-else></regiter>
</div>
<template id="tem">
<div>
姓名:<input><br>
性别:<input><br>
<button>登录</button>
</div>
</template>
<template id="temp">
<div>
姓名:<input><br>
性别:<input><br>
<button>注册</button>
</div>
</template>
<script src="vue.js"></script>
<script>
Vue.component("myCom",{
template:"#tem"
})
Vue.component("regiter",{
template:"#temp"
})
var vm=new Vue({
el:"#app",
data:{
flag:true
}
});
</script>
</body>
</html>