Home  >  Article  >  Web Front-end  >  What are the data interaction forms of Vue?

What are the data interaction forms of Vue?

零下一度
零下一度Original
2017-06-30 15:25:392215browse

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 request

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)})

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn