Modify the value in wx:if in WeChat Mini Programs.

clipboard.png

as shown in the figure above, how to use wx:if, in wx:for to dynamically modify the value of item.isCollected in wx:if.
look for an answer.

Feb.28,2021

wxml :

<view bindtap="tapHandler" data-index="{{index}}">

js :

tapHandler:function(e) {
    let index = e.currentTarget.dataset.index
    let items = this.data.items
    items[index].isCollected = !items[index].isCollected
    this.setData({
        items
    })
}
Menu