收藏
回答

求助,for循环中获取循环里面的input的值

我做了个优惠卷领取的页面,输入手机号的,点击领取的时候,把用户的手机号和优惠卷id传到后台,现在我获取不到用户输入的手机号了,求大神指教

<view class="container">

    <block wx:for="{{images}}"   >

        <view class="item" >

            <view class="viewimage">

            <image class="slide-image" src="{{item.imgUrl}}"/>

        </view>

        <view class="inputArea">

                <text class="textw">联系方式</text>

                        <input id="userPhone{{item.id}}" class="inputw"  bindinput="bindChange" placeholder=""  type="number" value="{{userPhone}}"/>  

                     <button type="" data-conponid="{{item.id}}"  bindtap="saveCoupon" class="lingqu">领取</button>

            </view>

        </view>

</block>

</view>


js

var mobile="";

bindChange:function(e,mobile){

mobile = e.detail.value;

console.log(mobile)


},

saveCoupon: function (e,mobile) {

console.log(e)

console.log(mobile);

var that = this;

console.log(that.data.userPhone)

},




回答关注问题邀请回答
收藏

2 个回答

  • 2018-07-06

    bindChange for循环出来共用一个函数的话 e.detail.value指向就有问题了 我猜想是这样的 没有运行不知道真实情况

    2018-07-06
    有用
    回复
  • 大海
    大海
    2018-07-06

    wx.createSelectorQuery()

    用这个API

    2018-07-06
    有用
    回复
登录 后发表内容