Vue实现简单的登陆方式切换
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src = "https://unpkg.com/vue"></script>
<title>登陆方式切换</title>
</head>
<body>
<div id = "app">
<div v-if = "seen"> <span>用户账号:</span> <input type="text" placeholder="请输入您的账号"></div>
<div v-else> <span>用户密码:</span> <input type="text" placeholder="请输入您的密码"></div>
<button @click = "switchButton">切换</button>
</div>
<script>
new Vue({
el:'#app',
data:{
seen:true
},
methods:{
switchButton(){
return this.seen = !this.seen;
}
}
});
</script>
</body>
</html>
效果图