Examples to explain vue v-for data processing

小云云
Release: 2018-05-18 10:04:26
Original
3633 people have browsed it

Earlier we shared with you the introduction of the v for command in the vue component and the analysis of alarm problems when using v-for. In this article, we will share with you vue v-for data processing and the basic use of v-for: use v- for="item in list" or v-for="item of list" to traverse, use list:list:[{n:1},{n:2},{n:3},{n:4}, {n:5},{n:6}] is used to facilitate expansion and is closer to actual project requirements.

  • {{item.n}}

Copy after login

v-for gives two parameters key and index

The traversed data needs to be divided into arrays and objects and treated separately

There is no key value under the array

The actual display effect of the parameter key value can be obtained under the object as follows:

  • {{item.n}}

    index={{ index }}

    key={{key}}

{{item}}:{{key}}:{{index}}

Copy after login

v-for supports equal number iteration

v-for="n in 10"

With this, you can load data step by step, just control the m value

{{list[i-1].n}}

Copy after login

Note:

You cannot use this binding component when traversing objects. You can only pass in index or other characteristic values in the processing function to select the current list, and then operate directly on the data array app.list[1]={n:33}. Assignment operations cannot trigger page updates

So vue js provides the array data update method of Vue.set(app.list,1,{n:33})

Related recommendations:

Introduction to the v for command in the vue component and analysis of alarm problems when using v-for

Tutorial on the loop use of the v-for command for common Vue.js commands

vue.js instruction v-for usage and index acquisition

The above is the detailed content of Examples to explain vue v-for data processing. 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!