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>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf3815-31e97.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf3815-31e97.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?