收藏
回答

请问向二维数组赋值后,view为什么取不到值?

page {
data: {
    i_1: [
      [{ name: '是1', value: '1'},{ name: '否', value: '0' }],
      [{ name: '是2', value: '1' },{ name: '否', value: '0' }]
    ],
    questions: ["1.AAA",
    "2.BBB"],
}
 
  radioChange: function (e) {
 
    var that = this;
    console.log('radio发生change事件,携带value值为:', e.detail.value);
    console.log('11223',e.currentTarget.dataset.index)
    var index = e.currentTarget.dataset.index;
    var radioItems = that.data.i_1[index];
 
    for (var i = 0, len = radioItems.length; i < len; ++i) {
      radioItems[i].checked = radioItems[i].value == e.detail.value;
    }
 
    var objName = "i_1["+index+"].text";
    that.setData({
      objName: radioItems
    });
 
    console.log("fuzhi:::::::",this.data.i_1);
  },


从console里可以看到,对象已经被赋值成功,但是 view里取到是空

<block wx:for="{{questions}}" wx:key="q">
 
      <view class="weui-cells__title">{{item}}</view>
      <view class="weui-cells weui-cells_after-title">
        <radio-group  data-index="{{index}}" bindchange="radioChange">
          <label class="weui-cell weui-check__label" wx:for="{{i_1[index]}}" wx:for-item="j" wx:key="value">
                <radio class="weui-check" value="{{j.value}}" checked="{{j.checked}}"/>
                <view class="weui-cell__bd">{{j.name}}</view>
                <view class="weui-cell__ft weui-cell__ft_in-radio" wx:if="{{j.checked}}">
                    <icon class="weui-icon-radio" type="success_no_circle" size="16"></icon>
                </view>
            </label>
        </radio-group>
      </view>
    </block>


应该怎么写,才能让view取到 checked 属性?

回答关注问题邀请回答
收藏
登录 后发表内容