微信小程序獲取input框的值


html

<view class="itemView">用戶名:
<input class="input" name="userName" placeholder="請輸入用戶名"
bindinput ="userNameInput"/>
</view>
<view class="itemView">密 碼:
<input class="input" password placeholder="請輸入密碼"
bindinput="passWdInput" />
</view>
<view class="viewName" style="background-color:#fbf9fe">
<button class="loginBtn" bindtap="loginBtnClick">登錄</button>
</view>

 

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 () {

}
})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM