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
    })
}
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-1b3680c-2c027.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-1b3680c-2c027.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?