微信小程序获取input框的值并进行传参

话不多说,直接上代码

wxml:

用户名:
  

密 码:
  


  

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)
    var _this = this;
    _this.setData({
      userName: this.data.userName,
      userPwd: this.data.userPwd,
    })
  },
  // 用户点击右上角分享
  onShareAppMessage: function() {

  }
})

你可能感兴趣的:(微信小程序)