<input data-idx="1" type="text" name="username" confirm-type="next" bindinput="usernameValue" bindconfirm="confirmListener" focus="{{focus && focusIndex == 1}}"/>
<input data-idx="2" type="text" name="password" bindinput="passwdValue" bindconfirm="confirmListener" focus="{{focus && focusIndex == 2}}" password/>
js:
data:{
focusIndex:1
},
confirmListener:function(e){
setTimeout(() => {
let currentIndex=e.currentTarget.dataset.idx
if(currentIndex < 2){
this.setData({
focusIndex:currentIndex + 1
})
}else{
this.setData({focus:false})
}
console.log(this.data.focusIndex)
}, 300);
},
动态修改focusIndex参数,currentIndex+1这个不对应该如何写?
let currentIndex=parseInt(e.currentTarget.dataset.idx)
console.log(this.data.focusIndex)
希望结果是2,显示11