swiper中嵌套嵌套radio-group ,为什么点其中一组,所有的全被触发了?
发布于 7 年前 作者 wanxia 12493 次浏览 来自 官方Issues

第一屏选啥,之后的都是一样的选项

<view class="box">
<swiper >
    <swiper-item wx:for="{{test}}" wx:key="key" wx:for-item="name">
        <view class="sub-box">
            <text>.{{name.timu}}</text>
        </view>
        <view class="option-box">
            <radio-group bindchange="f0" data-id="{{index}}"> 
                    <label wx:for="{{name.option}}"  wx:key="key" class="option {{options[index].checked==true?oStyle[oIndex]:''}}" >
                        <radio value="{{index}}" ></radio>
                        <text>{{optionArr[index]}}.{{item.name}}</text>
                    </label>
            </radio-group>
        </view> 
        <view class="key-box" wx:if="{{key[index]==1}}">
            <text class="ans">答案:{{name.da}}</text>
            <text class="key">{{name.jx}}</text>
        </view>
        <view class="card">
        </view>
    </swiper-item>
</swiper>
</view>
    f0:function(e){
        var index=e.currentTarget.dataset.id;
        this.setData({oIndex:index})
        var key=this.data.key
        var keyIndex=1
        if(key[index]!=1)key.push(keyIndex)
        this.setData({key})

        var options=this.data.test[index].option;
        for(var i=0;i<options.length;i++){
            options[i].checked=false
        }
        options[e.detail.value].checked=true;
        this.setData({options})
        var oStyle=this.data.oStyle
        if(!oStyle[index]) oStyle.push("")
        if(e.detail.value==this.data.test[index].da){
            oStyle[index]="oYes"
        }else{
            oStyle[index]="oNo"
        }
        this.setData({oStyle})
    }

回到顶部