Ai
1 Star 0 Fork 0

Bill/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue-login2.html 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
Bill 提交于 2019-06-30 21:37 +08:00 . chapter4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="../vue.js"></script>
<script src="../vue-resource.js"></script>
</head>
<body>
用户名:<input type="text" v-model="user"><br/>
密码:<input :type="passwordBtn" v-model="password"><br/>
<input type="button" value="submit" @click="login">
<input type="button" value="密码可见" @click="passBtn">
<script>
new Vue({
el:'body',
data:{
num:1,
msg:'hello vue!',
passwordBtn:'password',
user:'',
password:'',
},
methods:{
passBtn:function(){
this.num++;
this.num%2==0?this.passwordBtn='text':this.passwordBtn='password';
},
login:function(){
//这个方法是绑定在vue-resource库的,如果不引入那个库将无法使用
//console.log(this.$http);
this.$http.get('http://localhost:1234/a',{
user:this.user,
pass:this.password
}).then(function(data){
if(data.data.ok=='1'){
alert('登陆成功');
}else {
alert('登陆失败');
}
},function(){
alert('登陆失败');
});
//也可以不用then的第二个函数,用then的catch方法
//}).catch(function(){
// alert('登陆失败');
//})
}
}
})
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/bill_k_lin/Vue.git
git@gitee.com:bill_k_lin/Vue.git
bill_k_lin
Vue
Vue
master

搜索帮助