Home > Article > Web Front-end > What are the data interaction forms of Vue?
var that=this
get request
that.$http.get(" 1.txt").then(function(result){
##console.log(result)
this.msg=result.data ;
})
post request requires environment to send data and 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 request method cache whether to cache or not Reload
fetch("url",{method:"get",cache:"reload"}).then(function(){
})
##vue2 Request
axios({
url:"www.baidu.com?pageStart=18pageSize=3
",method:"get/post",
If it is a get request, use params to transmit data or address bar splicing
params:{
##pageStart:1 ,
pageSize:3
}
If it is a post request, use data to transmit Data
data:{
}
})
Instance
##Baidu cross-domain request
var that=this;
##that.$http.jsonp("
",{wd:this.abc},{jsonp:"cb"}).then(function(result){console. log(result.data.s)
})
360 Cross-domain requestthat.$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)})
The above is the detailed content of What are the data interaction forms of Vue?. For more information, please follow other related articles on the PHP Chinese website!