Detailed explanation of inserting duplicate data into arrays with Vue.js

小云云
Release: 2018-01-18 11:43:03
Original
2484 people have browsed it

This article mainly introduces the implementation code of Vue.js inserting repeated data into an array. Friends who need it can refer to it. I hope it can help everyone.

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

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

2.1 JavaScript code

 
Copy after login
Copy after login

2.2 html code

  • {{value}}

Copy after login

2.2 Result


3. Use track-by="$index" for array insertion. The array supports the insertion of duplicate data

3.1 Javascript code 3.2 HTML code

 
Copy after login
Copy after login

3.3 Results


##4. Complete code

  • {{value}}

Copy after login

ps: Let’s take a look at the vue array duplication and loop error

Vue.js does not support adding repeated data to the array by default. This can be achieved using track-by="$index".

Related recommendations:


Mysql deletes duplicate data and keeps the smallest id

Mysql query table duplicate data method

Processing of duplicate data in php array

The above is the detailed content of Detailed explanation of inserting duplicate data into arrays with Vue.js. 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
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!