wxml: 多个输入框等
<input type="text" bindinput="getval" data-vals="name"/>
<input type="text" bindinput="getval" data-vals="password"/>
{{password}}
<input type="text" bindinput="getval" data-vals="aihao"/>
<input type="text" bindinput="getval" data-vals="nike"/>
<input type="text" bindinput="getval" data-vals="like"/>
js:
getval(e){
console.log(e.detail.value);
console.log(e.target.dataset.vals);
this.setData({
[e.target.dataset.vals]:e.detail.value
})
}
小程序设置 表单 input 值