Home Web Front-end H5 Tutorial Solve the problem of red and warning when using v-for in vue

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

Mar 27, 2018 pm 04:02 PM
v-for Appear warn

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to enable Sensitive Content Warning on iPhone and learn about its features How to enable Sensitive Content Warning on iPhone and learn about its features Sep 22, 2023 pm 12:41 PM

Especially over the past decade, mobile devices have become the primary way to share content with friends and family. The easy-to-access, easy-to-use interface and ability to capture images and videos in real time make it a great choice for creating and sharing content. However, it's easy for malicious users to abuse these tools to forward unwanted, sensitive content that may not be suitable for viewing and does not require your consent. To prevent this from happening, a new feature with "Sensitive Content Warning" was introduced in iOS17. Let's take a look at it and how to use it on your iPhone. What is the new Sensitive Content Warning and how does it work? As mentioned above, Sensitive Content Warning is a new privacy and security feature designed to help prevent users from viewing sensitive content, including iPhone

What does wifi privacy warning mean? What does wifi privacy warning mean? Jun 09, 2023 am 10:21 AM

Privacy warnings are displayed on wifi because the network you join does not have a password or the password is too simple, or it is stolen. The solution is to set a more complex password for the wireless router.

Detailed explanation of v-for function in Vue3: perfect solution to list data rendering Detailed explanation of v-for function in Vue3: perfect solution to list data rendering Jun 18, 2023 am 09:57 AM

With the continuous advancement of digital technology, front-end development has become an increasingly popular profession. Vue3 has become the first choice of more and more developers due to its simplicity, ease of use, efficiency and stability. Among them, the v-for function is one of the core functions used for list data rendering in Vue3. In this article, we will provide a detailed explanation of the v-for function in Vue3, so that you can better use it to solve actual development problems. 1. Basic syntax The basic syntax of the v-for function is as follows: &lt;divv-

Best practices and performance optimization methods for using v-for in Vue Best practices and performance optimization methods for using v-for in Vue Jul 17, 2023 am 08:53 AM

Best practices and performance optimization methods for using v-for in Vue Introduction: In Vue development, it is very common to use the v-for instruction, which can conveniently traverse and render the data of an array or object onto the template. However, improper use of v-for may cause performance issues when dealing with large-scale data. This article will introduce the best practices when using the v-for directive and provide some performance optimization methods. Best practice: When using the v-for instruction in Vue to render each item of data using a unique Key value, you need to

Tips for using v-for to implement dynamic sorting in Vue Tips for using v-for to implement dynamic sorting in Vue Jun 25, 2023 am 09:18 AM

Vue is a modern JavaScript framework that helps us build dynamic web pages and complex applications easily. In Vue, you can easily create loop structures using v-for to iteratively render data. In some specific scenarios, we can also use v-for to implement dynamic sorting. This article will introduce how to use v-for to implement dynamic sorting techniques in Vue, as well as some application scenarios and examples. 1. Use v-for to make it simple

How to solve '[Vue warn]: v-for='item in items': item' error How to solve '[Vue warn]: v-for='item in items': item' error Aug 19, 2023 am 11:51 AM

How to solve the "[Vuewarn]:v-for="iteminiitems":item" error During the Vue development process, using the v-for directive for list rendering is a very common requirement. However, sometimes we may encounter an error: "[Vuewarn]:v-for="iteminiitems":item". This article will introduce the cause and solution of this error, and give some code examples. First, let’s understand

Which one has higher priority, v-if or v-for in vue? Which one has higher priority, v-if or v-for in vue? Jul 20, 2022 pm 06:02 PM

In vue2, v-for has a higher priority than v-if; in vue3, v-if has a higher priority than v-for. In vue, never use v-if and v-for on the same element at the same time, which will cause a waste of performance (each rendering will loop first and then perform conditional judgment); if you want to avoid this situation, Templates can be nested in the outer layer (page rendering does not generate DOM nodes), v-if judgment is performed at this layer, and then v-for loop is performed internally.

For artificial intelligence, humans really need to be in awe! The warning from the father of ChatGPT is worth heeding For artificial intelligence, humans really need to be in awe! The warning from the father of ChatGPT is worth heeding Jun 03, 2023 pm 06:37 PM

“Reducing the risk of AI wiping out the human race should be a global priority, along with other society-scale risks such as pandemics and nuclear war. It’s like a bucket of cold water being poured down, including by top experts in the field of AI.” AI Godfather"-level figures, industry leaders such as OpenAI CEO Sam Altman and DeepMind CEO Demis Hassabis, as well as hundreds of practitioners, jointly signed an open letter. In the letter, they called on governments and the public to be sufficiently cautious about artificial intelligence. They were worried that with the rapid advancement of AI technology, it may pose an existential threat to mankind. This is reminiscent of Musk’s warnings and calls for a moratorium on the development and development of large-scale artificial intelligence.

See all articles