Vue.js common instructions - tutorial on looping the v-for instruction

陈政宽~
Release: 2017-06-28 15:36:29
Original
1642 people have browsed it

This article mainly introduces you to the relevant information about the common instructions of Vue.js, the loop use of v-for instructions. The article introduces it in detail through the example code, which has certain reference and learning value for everyone. Friends who need it Let’s take a look below.

Preface

In Vue.js, the v-for directive requires special syntax in the form of item in items, items is the source dataArrayAnd item is an alias for array element iteration.

v-for can bind data to an array to render a list:


  1. {{ site.name }}

Copy after login


Output:

##Use v-for in template:


Copy after login


Effect:

v-for can iterate data through thepropertiesof an object:


  • {{ value }}

Copy after login


Effect:

Script House


http://www.jb51.net


A wonderful life is waiting for you to create it!


#v-for iterates data through the properties of an object. You can provide the second parameter as the key name:


  • {{ key }} : {{ value }}

Copy after login


Effect:

name : Script Home


url : http ://www.jb51.net


slogan: A better life is waiting for you to create it!


#v-for Iterates data through the properties of an object, taking the third parameter as theindex:


  • {{ index }} {{ key }}:{{ value }}

Copy after login


Effect:

0 name: Script House


1 url: http://www.jb51.net


2 slogan: A better life is waiting for you to create it!


v-for can also loopinteger


  • {{ n }}

Copy after login


Effect:


1 2 3 4 5 6 7 8 9 10
Copy after login


Summary

The above is the detailed content of Vue.js common instructions - tutorial on looping the v-for instruction. 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!