解决小程序警告:Now you can provide attr “wx:key” for a “wx:for” to improve performance.

2023-02-20 15:15:26 浏览数 (3)

首先,要说这是一个警告,不影响脚本正常运行。

修改方法:

在wx:for=”{{objentArray}}” 后增加 wx:key=”unique”,“unique”,

0 1 2 3 4 5 6 7 8 9

<switch wx:for=“{{objectArray}}” wx:key=“unique” style=“display: block;”>   {{item.id}} </switch> <button bindtap=“switch”> Switch </button> <button bindtap=“addToFront”> Add to the front </button> <switch wx:for=“{{numberArray}}” wx:key=“*this” style=“display: block;”>   {{item}} </switch> <button bindtap=“addNumberToFront”> Add to the front </button>

未经允许不得转载:肥猫博客 » 解决小程序警告:Now you can provide attr “wx:key” for a “wx:for” to improve performance.

0 人点赞