小程序獲取頁面上多個input值的案例:
//wxml<input class="formInput" placeholder="請輸入舊密碼" password placeholder-class="placeholderStyle" bindinput='inputWacth' data-model="oldPassword"> </input>
<input class="formInput" placeholder="請輸入新密碼" password placeholder-class="placeholderStyle" bindinput='inputWacth' data-model="newPassword"></input>
//js
data: {
oldPassword:'',
newPassword:''
},
inputWacth:function(e){
console.log(e);
let item = e.currentTarget.dataset.model;
this.setData({
[item]: e.detail.value
});
},