收藏
回答

自定义组件嵌套组件 wx:for item 作用域 出错怎么办

json 数据  :

"[[{"name":1,"value":""},{"name":2,"value":""},{"name":3,"value":""}],[{"name":4,"value":[{"name":1,"value":[{"name":1,"value":""},{"name":2,"value":""},{"name":3,"value":""}]},{"name":5,"value":[{"name":1,"value":""},{"name":2,"value":""},{"name":3,"value":""}]},{"name":6,"value":[{"name":1,"value":""},{"name":2,"value":""},{"name":3,"value":""}]}]}],[{"name":7,"value":""},{"name":8,"value":""},{"name":9,"value":""}]]"


组件 wxml:

<view class="question-all-box" wx:for="{{testQuestionList}}" wx:for-item="item1" wx:for-index="index1">
  <view class="question-type-name" wx:if="{{!item1.questionlevel}}">{{item.structureName}}</view>
 
  <view class="clearfix" wx:for="{{item1.exerciseStructureVos}}" wx:for-item="item2" wx:for-index="index2">
 
    <view class='margin-bottom-20' class='red pull-left' wx:if="{{!item2.exerciseStructureVos.length}}"
    wx:for="{{item2}}" wx:for-item="item3" wx:for-index="index3">
      <text>{{item3.orderInType}}</text>
    </view>
 
    <view class='margin-bottom-20' class='coral pull-left' wx:if="{{item2.exerciseStructureVos.length}}">
      <text>{{item2.orderInType}}</text>
      <markErrorModule testQuestionList="{{item2}}"></markErrorModule>
    </view>
 
  </view>
 
</view>

定义个组件 然后 组件中 再嵌套 这个组件 时 wx:for 循环时在  <markErrorModule testQuestionList="{{item2}}"></markErrorModule> 嵌套组件循环时出错了 item的作用域出错。

最后一次编辑于  2018-01-22  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏关注问题回答