How WeChat Mini Programs binds dynamic control attributes in wxml

WXML

  <block wx:for="{{images}}" wx:key="*this" wx:for-index="idx">
          <view wx:if="{{"item"+idx > 0}}" class="q-image-progress">
            
          </view>
           <image src="{{item}}" mode="aspectFill" data-idx="{{idx}}" bindtap="handleImagePreview"></image>
   </block>

js

onLoad: function(options) {
    let images=["0.jpg"];
    for(let i=0;i<images.length;iPP){
      const key = `item${i}`
      console.log(key)
      this.setData({
        [key]:0
      })
    }
}

I want to get the dynamically generated value of "item"+idx in wxml, and now" item"+idx"in wx:if= "{{"item"+idx > 0}" generates the string item0 directly instead of getting the value of item0 in JS.
could you tell me how to get the dynamically generated values in JS in wxml?


it should not be possible to access variables directly. You can consider changing the storage structure, similar to

.
// js
list:{
  item0:'',
  item1:'',
}

// wxml
<view wx:if="{{list['item'+idx]}}"></view>
Menu