Vue resource send request

Time:2019-11-4
vue-resource
    



    
       
       
    





    < span style = "background color:" f5f5f5; color: "008000;" > // / span > < span style = "background color:" f5f5f5; color: "008000;" > Vue promise is based on Vue, so when introducing CDN library, attention should be paid to the order. Vue should be introduced first</span>
<span style="background-color: #f5f5f5; color: #000000;">    let vm </span><span style="background-color: #f5f5f5; color: #000000;">=</span> <span style="background-color: #f5f5f5; color: #0000ff;">new</span><span style="background-color: #f5f5f5; color: #000000;"> Vue({
        el: </span><span style="background-color: #f5f5f5; color: #000000;">"</span><span style="background-color: #f5f5f5; color: #000000;">#app</span><span style="background-color: #f5f5f5; color: #000000;">"</span><span style="background-color: #f5f5f5; color: #000000;">,
        data:{
        },
        Methods: {< / span > < span style = "background color:" f5f5f5; color: "008000;" ></span>
<span style="background-color: #f5f5f5; color: #000000;">            getInfo(){
               </span><span style="background-color: #f5f5f5; color: #0000ff;">this</span><span style="background-color: #f5f5f5; color: #000000;">.$http.get(</span><span style="background-color: #f5f5f5; color: #000000;">'</span><span style="background-color: #f5f5f5; color: #000000;">https://www.easy-mock.com/mock/5d537a1cf651bc6ff265fb77/example/result/cart.json</span><span style="background-color: #f5f5f5; color: #000000;">'</span><span style="background-color: #f5f5f5; color: #000000;">) 
                .then(res</span><span style="background-color: #f5f5f5; color: #000000;">=></span><span style="background-color: #f5f5f5; color: #000000;">{
                    console.log(res);
                })
            },
            postInfo(){
                </span><span style="background-color: #f5f5f5; color: #0000ff;">this</span><span style="background-color: #f5f5f5; color: #000000;">.$http.post(</span><span style="background-color: #f5f5f5; color: #000000;">'</span><span style="background-color: #f5f5f5; color: #000000;">https://www.easy-mock.com/mock/5d537a1cf651bc6ff265fb77/example/upload</span><span style="background-color: #f5f5f5; color: #000000;">'</span><span style="background-color: #f5f5f5; color: #000000;">,{},{
                    Emulatejson: < / span > < span style = "background color: if f5f5f5; color: if 000ff;" > true < / span > < span style = "background color: if f5f5f5; color: 008000;" // // / span > < span style = "background color: if f5f5f5f5; color: if 008000;" > set this parameter to the application / x-www-form-urlcodecodecodecodecodeapplication / x-www-form-urlcodecodecodecodeform-form-urlf5f5f5f5; color: 008000; "> span style =" background color: if f5f5f5f5; color: if 008000; "> set this parameter to the application / x-www-form-urlcodecodeapplication / x-www-form-form-urlcodecodeapplication / x-form-form ed, because there is no default form format for manually submitting requests, you need to set the number to send According to the format</span>
<span style="background-color: #f5f5f5; color: #000000;">                })
                .then(res</span><span style="background-color: #f5f5f5; color: #000000;">=></span><span style="background-color: #f5f5f5; color: #000000;">{
                    console.log(res.body);
                })
            },
            }
    });
</span>