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.
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:
index={{ index }}
key={{key}}
{{item}}:{{key}}:{{index}}
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}}
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!