微信小程序-form表单-获取用户输入文本框的值
// 获取昵称 nickname: function(e) { this.setData({ nickname: e.detail.value, }) console.log("昵称" + this.data.nickname); }, // 获取姓名 realName: function(e) { this.setData({ realName: e.detail.value, }) console.log("姓名" + this.data.realName); }, // 获取详细地址 detailAddress: function(e) { this.setData({ detailAddress: e.detail.value, }) console.log("详细地址" + this.data.detailAddress); this.setData({ detailAddress: e.detail.value, }) console.log("详细地址" + this.data.detailAddress); }, 保存 baocun: function(e) { console.log("昵称:" + this.data.nickname + " 真实姓名:" + this.data.realName + "性别:" + this.data.sex + "详细地址" + this.data.detailAddress); },复制代码
复制代码
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.password); }复制代码
form表单
复制代码
formSubmit: function (e) { console.log('form发生了submit事件,携带数据为:', e.detail.value); },let app = getApp();Page({ data: { phone: "", pwd: "", sex: "男" }, formSubmit: function (e) { console.log('form发生了submit事件,携带数据为:', e.detail.value); let { phone, pwd, isPub, sex } = e.detail.value; this.setData({ warn: "", isSubmit: true, phone, pwd, isPub, sex }) }, formReset: function () { console.log('form发生了reset事件') }})复制代码