收藏
回答

多层循环后点击子元素怎么获得父元素的下标值?

<block wx:for="{{a}}" wx:for-item="item" >
    <view data-index="{{index}}">   
     <block wx:for="{{item.b}}" >
                <input type="text" bindfocus="index"  data-index="{{index}}">
        </block>
    <view>
</block>


input获得焦点的时候怎么获取上一层循环的index呢?

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

3 个回答

  • le
    le
    2017-09-22



    自己定义index和item

    <block wx:for="{{a}}" wx:for-index="father_index" wx:for-item="father_item">

      <view data-index="{{father_index}}">

        <block wx:for="{{father_item}}" wx:for-index="son_index" wx:for-item="son_item">

          <input type="text" value="{{son_item.value+father_index+son_index}}" data-index="{{father_index}}" />

        </block>

      </view>

    </block>


    data: {

        a: [

          [{ value: "a" }, { value: "b" }, { value: "c" }],

          [{ value: "d" }, { value: "e" }, { value: "f" }],

          [{ value: "g" }, { value: "h" }, { value: "i" }]

        ]

      }


       


    咫尺开发论坛——小乐    


    2017-09-22
    有用
    回复
  • 前路漫漫
    前路漫漫
    2017-09-21

    学习了

    2017-09-21
    有用
    回复
  • 前路漫漫
    前路漫漫
    2017-09-21

    父元素的下标值存下来


    2017-09-21
    有用
    回复
登录 后发表内容