Home>Article>Web Front-end> vue.js method of operating array data

vue.js method of operating array data

php中世界最好的语言
php中世界最好的语言 Original
2018-04-14 15:27:03 3171browse

This time I will bring you the method of operating array data in vue.js. What are theprecautions for operating array data in vue.js? Here are the actual cases, let’s take a look.

1. By default, Vue.js does not support adding repeated data to an array. This can be achieved usingtrack-by="$index".

2. Do not use track-by="$index" for array insertion. The array does not support the insertion of duplicate data

2.1

JavaScriptcode

 
2.2 html code

  • {{value}}

3. Use track-by="$index" to insert into the array. The array supports the insertion of repeated data

3.1 Javascript Code 3.2 html code

 
4. Complete code

  • {{value}}

ps: Let’s take a look at the vue array duplication,

LoopError reportingVue.js does not support adding repeated data to arrays by default. This can be achieved usingtrack-by="$index"

.

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:


The above is the detailed content of vue.js method of operating array data. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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