<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<input :type="type"><button @click="pwd">{{message}}</button>
</div>
<script>
var vm = new Vue({
el:"#app",
data:{
type: "password",
message:"显示密码",
},
methods:{
pwd(){
if(this.type==="password") {
this.type = "text";
this.message="隐藏密码";
}else{
this.type="password";
this.message="显示密码";
}
}
}
});
</script>
</body>
</html>