Vuejslearn---v-for list rendering

Source: Internet
Author: User

Vue.js is a library that builds a data-driven Web interface. Focus on the ViewModel layer of the MVVM pattern, so it's easy to integrate with other libraries or existing projects

The core of Vue.js is a responsive data-binding system that keeps data synchronized with the DOM very simple

As shown in the following table, when we get the data from the backend interface or JSON file using AJAX, we have the N-way to render the data to the page.

1. Use JS for loop to traverse the fill

2.ng of Ng-repeat

Today we use Vue.js's v-for

First, the HTML

<Divclass= "Shop_list_box">     <ul>        <Li><span>Bengbu</span><span>Fengyang Dong Lu</span></Li>        <Li><span>Bengbu</span><span>Fengyang Dong Lu</span></Li>    </ul></Div>

Two

JSON data node

Third, using v-for binding data to the page

Referencing vue.js, the request data succeeds after instantiating a vue. El is bound to that element under the

Notice here when an array of bread has some objects---->{} or [{},{},{}]

function (DAT) {                        var data = dat.cstore           //  console.log (data)                        var  New  Vue ({                ' #example ',                data: {                    items:data                }})        });
View Code

<Divclass= "Shop_list_box">                      <ulID= "Example">                          <Liv-for= "Item of items">                              <span>{{item.city}}</span><span>{{Item.shop}}</span>                          </Li>                                               </ul>                  </Div>
View Code

It's OK to be here.

However, you can also use template v-for

Template v-for similar to V-for

{{item.city}} can also be replaced with v-text= "item.city", the advantage is that the data is not loaded when you do not see the {{}} placeholder

Vuejslearn---v-for list rendering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.