微信小程序获取input框的值

我不是女神ヾ 2022-04-02 10:27 400阅读 0赞
  1. <view class="itemView">用户名:
  2. <input class="input" name="userName" placeholder="请输入用户名"
  3. bindinput ="userNameInput"/>
  4. </view>
  5. <view class="itemView">密 码:
  6. <input class="input" password placeholder="请输入密码"
  7. bindinput="passWdInput" />
  8. </view>
  9. <view class="viewName" style="background-color:#fbf9fe">
  10. <button class="loginBtn" bindtap="loginBtnClick">登录</button>
  11. </view>
  12. Page({
  13. data: {
  14. userName: '',
  15. userPwd:""
  16. },
  17. //获取用户输入的用户名
  18. userNameInput:function(e)
  19. {
  20. this.setData({
  21. userName: e.detail.value
  22. })
  23. },
  24. passWdInput:function(e)
  25. {
  26. this.setData({
  27. userPwd: e.detail.value
  28. })
  29. },
  30. //获取用户输入的密码
  31. loginBtnClick: function (e) {
  32. console.log("用户名:"+this.data.userName+" 密码:" +this.data.userPwd);
  33. }
  34. ,
  35. // 用户点击右上角分享
  36. onShareAppMessage: function () {
  37. }
  38. })

转载地址:https://blog.csdn.net/qq_40536470/article/details/81101804

发表评论

表情:
评论列表 (有 0 条评论,400人围观)

还没有评论,来说两句吧...

相关阅读

    相关 程序input传参

    在微信小程序中原生input组件无法直接传参,但可以通过自定义属性的方式达成效果 <!-- 自定义属性的命名格式为“data-自定义名字” --> <inpu