Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use v-for in vue

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use v-for in vue. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Usage: 1, using "vmurf =" (item,i) in list "to loop the ordinary array; 2, using" vmurf = "(user,i) in list" circular array object; 3, using "vmurfort =" (val,key,i) in user "" to loop the object.

This article operating environment: windows10 system, Vue2.9.6 version, DELL G3 computer.

The usage of v-for in vue

Several applications of v-for:

Method 1: v-for loop ordinary array / / local egg method:

{{list [0]}}

{{list [1]}}

{{list [2]}}

{{list [3]}}

{{list [4]}}

/ / v-for method: {{I}}, {{item}}

/ / Array data part: data: {list: [1 user.id 2je 3je 4je 5je 6]}, method 2: v-for loop object array / / v-for usage: {{user.id}}, {{user.name}}, {{I}}

/ / Array data part: list: [{id:1,name: "zs1"}, {id:2,name: "zs2"}, {id:3,name: "zs3"}, {id:4,name: "zs4"},] method 3: v-for loop object

Note: when traversing the key-value pair on the object, in addition to val key, there is also an index value in the third position

/ / v-for method {{val}}, {{key}}

/ / object part: user: {id:1, name: "Chocolate" gender: "cute Girl"} method 4: v-for iterative array / / in after we let go of the normal array object array objects can also put numbers / / Note: if you use v-for to iterate the number, the previous count value starts at 1, which is the {{count}} cycle.

This is the end of the article on "how to use v-for in vue". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report