代码如下:
<view class=‘flex-justify_center’ wx:for="{{poetry}}" wx:for-index=“idx” wx:for-item=“poetryLine”>
<button class=‘image_style_left’ style=’ background-color: #eeeeee;’ mode=‘aspectFit’ src=’’ bindtap=‘selectPoetryLingLeft’ data-poetryleft=" {{poetryLine.left}}" disabled=’{{disabled_left}}’
id=’{{idx}}’>
{{poetryLine.left}}</button>
<!-- {{poetryLine.left}} -->
<button class=‘image_style_right’ style=’ background-color: #eeeeee;’ mode=‘aspectFit’ src=’’ bindtap=‘selectPoetryLingRight’ data-poetryright=" {{poetryLine.right}}" disabled=’{{disabled_right}}’>
{{poetryLine.right}}</button>
<!-- {{poetryLine.right}} -->
</view>
问题:通过for循环创建了很多button,现在我想对点击的button做disabled=true的处理。怎么实现啊。就是说想对单个的button做disabled的处理。目前就是一改全部都改掉了
<view class='flex-justify_center' wx:for="{{poetry}}" wx:for-index="idx" wx:for-item="poetryLine">
<button class='image_style_left' style=' background-color: #eeeeee;' mode='aspectFit' src='' bindtap='selectPoetryLingLeft' data-poetryleft=" {{poetryLine.left}}" disabled='{{disabled_left}}'
id='{{index}}'>
{{poetryLine.left}}</button>
<!-- {{poetryLine.left}} -->
<button class='image_style_right' style=' background-color: #eeeeee;' mode='aspectFit' src='' bindtap='selectPoetryLingRight' data-poetryright=" {{poetryLine.right}}" disabled='{{disabled_right}}'>
{{poetryLine.right}}</button>
<!-- {{poetryLine.right}} -->
</view>
这样在JS的回调中根据ID就可以判断点击的是哪一个button了