一丶案例需求
(一)用户在登录时,可以切换用户账号登录还是邮箱账号登录
二丶案例代码
<!--作者:key-->
<!--浏览工具:Chrome-->
<!--开发工具:WebStorm-->
<!--开发时间:2020/11/17 0:05-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<span v-if="isUser">
<label for="username">用户账号</label>
<input type="text" id="username" placeholder="用户账号">
</span>
<span v-else>
<label for="email">用户邮箱</label>
<input type="text" id="email" placeholder="用户邮箱">
</span>
<button @click="isUserClick()">切换登录方式</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app = new Vue({
el:"#app",
data:{
message:"Hello Ting,I am Key!",
isUser:false,
},
methods:{
isUserClick(){
this.isUser = !this.isUser;
}
},
})
</script>
</body>
</html>
三丶运行结果