$.ajax () combine with Vue to get data and render

Source: Internet
Author: User

Html:

<div id= "App1" >    <ul>        <li v-for= "item in Datas" >            <div href= "" >                <div v-text = "Item.time" ></div>                <div href= "" v-for= "Item1 in Item.list" >                    <div v-text= "Item1.type" > </div>                    <div v-text= "Item1.money" ></div>                </div>            </div>        </li>    </ul></div>

Js:

var vmm=new Vue ({    el: "#app1",    data: {        datas: []     },    mounted:function () {        this.showdata ();        The method that needs to be executed can be triggered in the mounted, the obtained data can be placed in the previous rendering    },    methods:{        showdata:function () {            Jquery.ajax ({                type: ' Get ',                URL: "Data-data.json",            //Data:{type:type,ext:ext},              datatype: "JSON ",              success:function (data) {for                (var i=0;i<data.length;i++) {                vmm.datas.push (data[i]);              }               Console.log (Vum.datas);}}           );

Data-data.json:

[  {    "time": "2017-10-10",    "list": [      {"type": "Consumption (order number 101010101010)", "Money": "99.00"},      {"type": "Stored value (order number 101010101010)", "Money": "78.00"},      {"type": "Refund (order number 101010101010)," "" "", "" 66.00 "}    ]  },  {    "Time": "2017-08-16",    "list": [      {"type": "Consumption (order number 101010101010)", "Money": "99.00"},      {"type": " Stored value (Order number 101010101010) "," Money ":" 78.00 "},      {" type ":" Refund (order number 101010101010) "," "" "," "66.00"}    ]  },  {    "time": "2017-07-16",    "list": [      {"type": "Consumption (order number 101010101010)", "Money": "99.00"},      {" Type ":" Stored value (order number 101010101010) "," Money ":" 78.00 "},      {" type ":" Refund (order number 101010101010) "," "", "" 66.00 "}    ]  }]

Https://www.cnblogs.com/yg_zhang/p/6158612.html

77369749

$.ajax () combine with Vue to get data and render

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.