Data Interaction modes of several vue and vue interaction modes

Source: Internet
Author: User

Data Interaction modes of several vue and vue interaction modes

Var that = this

 

Get request

That. $ http. get ("1.txt"). then (function (result ){

Console. log (result)

This. msg = result. data;

})

Post requests require the environment to send data to receive data

That. $ http. post ("1.txt"," "). then (function (result ){

Console. log (result)

})

Comprehensive request

That. $ http ({

Method: "get ",

Url: "1.txt"

}). Then (function (result ){

Console. log (result. data)

})

Es6 Request method: whether the cache is reloaded or not

Fetch ("url", {method: "get", cache: "reload"}). then (function (){

 

})

Vue2 request

Axios ({

Url :"Www.baidu.com? PageStart = 18 pageSize = 3",

Method: "get/post ",

If it is a get request, use params to transmit data or splice the address bar

Params :{

PageStart: 1,

PageSize: 3

}

Use data to transmit data for post requests

Data :{

}

})

 

Instance

Baidu cross-origin request

Var that = this;

That. $ http. jsonp ("Https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su", {Wd: this. abc}, {jsonp:" cb "}). then (function (result ){

Console. log (result. data. s)

})

360 cross-origin requests

That. $ http. jsonp ("https://sug.so.360.cn/suggest? Encodein = UTF-8 & encodeout = UTF-8 ", {word: this. abc}, {emulateJSON: true}). then (function (result ){

Console. log (result. data. s )})

Related Article

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.