微信小程序——获取用户输入文本框的值

小程序不支持dom所以document.getElementById不可使用。

非form表单提交

login.wxml

用户名:


密 码:



登录

login.js

// pages/index/login.js
Page({
data: {
userName: ‘’,
userPwd:""
},
//获取用户输入的用户名
userNameInput:function(e)
{
this.setData({
userName: e.detail.value
})
},
passWdInput:function(e)
{
this.setData({
userPwd: e.detail.value
})
},
//获取用户输入的密码
loginBtnClick: function (e) {
console.log(“用户名:”+this.data.userName+" 密码:" +this.data.userPwd);
}
,
// 用户点击右上角分享
onShareAppMessage: function () {

}
})

猜你喜欢

转载自blog.csdn.net/weixin_44825473/article/details/88925187