小程序for循环中input事件的处理

js

bindManual: function(e){
var that= this;
var id = e.currentTarget.id;
console.log(id)
that.setData({
num: e.detail.value
})
console.log(that.data.num)
},
bindMinus: function(e){
var that = this
var index = e.currentTarget.id
var newnum = that.data.num
--newnum
var newarr = that.data.newarry
newarr[index] = newnum
that.setData({
newarry: newarr
})
},
bindPlus: function(e){
var that = this
var index = e.currentTarget.id
var newarr = that.data.newarry
var newnum = that.data.num
newnum++
newarr[index] = newnum
that.setData({
newarry: newarr
})
},
wxml

< scroll-view class= "attr" scroll-y= "true">
< checkbox-group bindchange= "checkboxChange" wx:for= "{{priceCombos}}" data-index= "{{index}}">
< view class= 'package'>
< checkbox value= "key1" checked= "" / >< text >{{item.comboExtra}} </ text >< text class= 'pricecolor'>¥39999 </ text >
< view class= "num">
< view class= "stepper">
<!-- 减号 -->
< text class= "{{goods_number == 1 ? 'disabled' : 'normal'}}" bindtap= "bindMinus" id= '{{index}}'>- </ text >
<!-- 数值 -->
< input type= "number" bindchange= "bindManual" value= "{{newarry[index]||1}}" id= '{{index}}' / >
<!-- 加号 -->
< text class= "normal" bindtap= "bindPlus" id= '{{index}}'>+ </ text >
</ view >
< label >购买数量 </ label >
</ view >
< view class= 'explain'>{{item.comboDesc}} </ view >
</ view >
</ checkbox-group >
</ scroll-view >
怎么能使操作for循环里的单个input,我改变第一个value的值第二个也会变

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值