循环出多个input值
发布于 6 年前 作者 fang61 6987 次浏览 来自 问答

–问题–我想在js中循环出input的value值,包括点击它改变时。我现在想在name中加{{index}},但我不知道怎么输出。–html代码–

<view class=‘product_sku_price’ wx:for="{{product_sku_price}}" wx:key="{{index}}" wx:for-index=“index” wx:for-item=“vo” style=‘margin-top:20rpx;’>

      <view style=‘display: flex;flex-direction:row;margin-bottom:10rpx;font-size:32rpx;’>

        <text style=‘color:#666;width:calc(100% - 120px);’>{{vo.store_items}}</text>

          <input type=“number” value=’{{vo.store_price}}’ style=‘text-align:center;width:120rpx;’ bindinput=‘changeprice’ name=“store_price{{index}}” bindinput=“inputTyping” data-index=’{{index}}’ />

     </view></view>

–js–

inputTyping: function (e) {

    var index = parseInt(e.currentTarget.dataset.index);

    this.setData({

      store_price: e.detail.value.store_price[index]

    })

  },

回到顶部