报错:Now you can provide attr `wx:key` for a `wx:for` to improve performance

简介: 报错:Now you can provide attr `wx:key` for a `wx:for` to improve performance

@[toc]

问题

在小程序开发时出现缺少wx:key的错误

报错

Now you can provide attr wx:key for a wx:for to improve performance

在这里插入图片描述

解决办法

在使用wx:for遍历的时候,未绑定key值
绑定 方法:wx:key="index"wx:key="this"

<!--wxml-->
<view wx:for="{
    
    {array}}" wx:key="index"> {
    
    {
    
    index}}-{
    
    {
    
    item}}</view>
// page.js
Page({
   
   
  data: {
   
   
    array: [1, 2, 3, 4, 5]
  }
})
相关文章
|
6月前
|
JavaScript
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
652 0
|
4月前
|
前端开发
前端使用 <el-descriptions>标签报错: <el-descriptions> - did you register the component correctly
前端使用 <el-descriptions>标签报错: <el-descriptions> - did you register the component correctly
311 0
|
6月前
|
开发工具
App Store Connect Operation Error ERROR ITMS-90087: “Unsupported Architectures
App Store Connect Operation Error ERROR ITMS-90087: “Unsupported Architectures
53 1
|
6月前
|
JavaScript
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
|
11月前
|
JavaScript
Uncaught runtime errors: × ERROR Avoided redundant navigation to current location: “/xxx“.
Uncaught runtime errors: × ERROR Avoided redundant navigation to current location: “/xxx“.
161 0
|
11月前
|
Rust 小程序
小程序警告:Now you can provide attr wxkey for a wxfor to improve performance
首先,无论什么程序,控制台中的警告都是会影响程序性能的。我们需要减少此类警告的出现,以提高程序的运行性能。 小程序开发的时候,遇到了如下的警告:
159 0
|
JavaScript
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
175 0
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
|
JavaScript
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent .(二)
1.在data中声明一个变量接收props的值,然后再去改变data里的这个值 2. 用computed属性 3.用data保存数据,watch监听
|
JavaScript
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent .(一)
大致意思就是props接收到的从父组件传过来的tableData不能直接修改。
140 0
|
数据可视化 数据挖掘 开发者
Data-Basic Statistical Descriptions of Data| 学习笔记
快速学习 Data-Basic Statistical Descriptions of Data。
Data-Basic Statistical Descriptions of Data| 学习笔记