关于循环数据的问题?

小程序 文章 2020-08-31 16:21 509 0 全屏看文

AI助手支持GPT4.0

关于循环数据的问题?Questions about circular data?

关于循环数据的问题?

小程序报VM13:1 Do not set same key "[object Object]" in wx:key.不能设置相同的键,但是后台获取的数据没有位移的键值,所有循环只能写wx:key="index",但是这样写键又相同了,这该怎么办呢

The applet reports vm13:1 do not set the same key "[object object]" in Wx: key. The same key cannot be set, but the data obtained from the background has no offset key value. All loops can only write Wx: key = index ", but the same key is written in this way. What should we do

回答:

Distance:

数据结构里没有唯一的id或者其他字段吗?每条数据不同的话也能用wx:key="item"的

lz:没有唯一的id,用wx:key="item"也不得
陈宇明:

去掉wx:key

lz:去掉也不行,去掉就提示 Now you can provide attr `wx:key` for a `wx:for` to improve performance.
Ac🚬zy:

wx:key="item"

wx:key="*this"

lz:这两个方法都试了,不得,也是提示不能设置相同的键
stop eating:

没明白,索引为什么会相同?

lz:不知道什么原因,直接拿索引就提示相同
stop eating:提供下代码吧,这是个警告,不解决也没事的。你可以遍历数据加个唯一键,也可以让后端补充上,解决问题的办法有很多

-EOF-

AI助手支持GPT4.0