Home > Web Front-end > H5 Tutorial > body text

Solve the problem of red and warning when using v-for in vue

php中世界最好的语言
Release: 2018-03-27 16:02:21
Original
2880 people have browsed it

This time I will bring you a solution to v-for using red and warning in vue, vue to solve v-for using red and warning What are the precautions , the following is a practical case , let’s take a look.

Code red reporting is very uncomfortable for patients with obsessive-compulsive disorder who pursue beautiful code. The red reporting is as follows:

There will also be prompts like this in the console:

(Emitted value instead of an instance of Error) <Option v-for="item in searchTypeList">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.
Copy after login

. To solve this problem of red reports, we need to follow his prompts and add a unique one when loop key, choose to use index here:

<ul 
class="clearfix course-list">
<li 
class="left" 
v-for="(item,index)
in gradeClassfy.primary.grade"
:key="index"><a
href="#" rel="external nofollow" >{{item.name}}</a></li>
</ul>
Copy after login

In this way, the red report disappears.

The above article is based on solving the problem of red reporting and warning when using v-for in vue. This is all the content shared by the editor. I hope it can give you a reference. I also hope that Please support Script House a lot.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed graphic explanation of Vue.directive()

Detailed explanation of JsChart component usage

The above is the detailed content of Solve the problem of red and warning when using v-for in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!