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>

 

Recommended Today

The use of progressbarcontrol, a progress bar control of devexpress – Taking ZedGraph as an example to add curve progress

scene WinForm control – devexpress18 download installation registration and use in vs: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100061243 When using ZedGraph to add curves, the number of curves is slower if there are many cases. So in the process of adding curve, the progress needs to be displayed, and the effect is as follows     Note: Blog home page:https://blog.csdn.net/badao_liumang_qizhi […]