首页 > 其他分享 >Elements in iteration expect to have 'v-bind:key' directives.

Elements in iteration expect to have 'v-bind:key' directives.

时间:2024-05-08 18:15:12浏览次数:13  
标签:Elements bind iteration directives vetur key expect

当组件中使用v-for时,如果不指定key,则会有红色警告信息。解决方案如下。

方案一:绑定key(亲试有效)

//方式一
<li v-for="(item, index) in list" :key="index">

//方式二
<li v-for="(item, index) in list" :key="item.id">

//方式三
<li v-for="(item, index) in list" v-bind:key=index>

//方式四
<li v-for="(item, index) in list" v-bind:key=item.id>

方案二:更改编辑器配置(未尝试)

更改vetur配置    vscode->文件->首选项->设置->搜索(vetur)

把  "vetur.validation.template": true  改成  false

标签:Elements,bind,iteration,directives,vetur,key,expect
From: https://www.cnblogs.com/mingcore/p/18180454

相关文章

  • 一个pybind11的例子
    首先在当前文件夹下安装pybind11。然后编写以下3个文件:1、CMakeLists.txtcmake_minimum_required(VERSION3.5)project(exampleLANGUAGESCXX)add_subdirectory(pybind11)pybind11_add_module(barbar.cpp)2、foo.pyimportbarhello_world=bar.HelloWorl......
  • WPF Text MultiBinding StringFormat
    <TextBlock.Text><MultiBindingStringFormat="R:{0:N0},G:{1:N0},B:{2:N0}"><BindingPath="Value"ElementName="_red"/><BindingPath="Value"ElementName="_green"/>......
  • WPF MultiBinding
    <Windowx:Class="WpfApp84.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.......
  • WPF DataContext="{Binding SelectedItem,ElementName=_master}"
    <Windowx:Class="WpfApp80.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.......
  • 【Android】Binder的Oneway拦截
    在某些虚拟化,免安装,打点,环境检测,拦截器等场景,针对Android系统服务接口的拦截是常用的技术方案。通常只是针对正向的接口调用,如果涉及被动的服务回调拦截,则实现起来就有些许麻烦。说明由于我们容器产品的特性,需要将应用完整的运行起来,所以必须要对各系统服务(超过100+系统服务)......
  • NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    NoClassDefFoundError:org/slf4j/impl/StaticLoggerBinderSpringBoot2.7.xxxlogback1.3.xxx实际上原因是logback-classic从v1.3.0中删除了org/slf4j/impl/StaticLoggerBinder,而spring-boot2.x只支持logback到v1.2.x(目前是1.2.12)。以下是相关问题:https://github.com/sprin......
  • vscode 快捷件的配置文件地址 C:\Users\Reciter\AppData\Roaming\Code\User\ke
    vscode快捷件的配置文件地址C:\Users\Reciter\AppData\Roaming\Code\User\keybindings.json更改快捷键冲突我要把QuickGoToSelectedFilePath插件的快捷键Ctrl+E,换成F12,插件文章:https://www.cnblogs.com/pengchenggang/p/18163728但是系统里面已经有好几个F12的......
  • 手写bind函数
    今天无事手写一个bind函数//重写bind函数Function.prototype.bindDemo=function(){//arguments可以获取到传的参数//1.先把获取到的数据转换为数组的格式letargs=Array.prototype.slice.call(arguments);//2.获取数组中第一个元素,即this即将指向的数据le......
  • Web Component addEventListener .bind(this)的函数带参数引起的报错
     一开始这样写:  this.shadowRoot.querySelector('.prev').addEventListener('click',this.moveSlide(1).bind(this));报错:UncaughtTypeError:Cannotreadpropertiesofundefined(reading'bind')    以为是前面的DOM获取不对,但是怎么改都不对,网上查询后......
  • Docker(十五)-Docker的数据管理(volume/bind mount/tmpfs
    Docker提供了三种不同的方式用于将宿主的数据挂载到容器中:volumes,bindmounts,tmpfsvolumes。当你不知道该选择哪种方式时,记住,volumes总是正确的选择。volumes是Docker数据持久化机制。bindmounts依赖主机目录结构,volumes完全由Docker管理。Volumes有以下优点:Volumes更容易备......