首頁  >  文章  >  web前端  >  vue的資料互動形式有哪些

vue的資料互動形式有哪些

零下一度
零下一度原創
2017-06-30 15:25:392159瀏覽

var that=this

 

#get請求

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

console.log(result)

this.msg=result.data ;

})

post請求   需要環境 傳送資料 接收資料

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

#console.log(result)

})

綜合性請求

that.$http({

method: "get",

url:"1.txt"

#}).then(function(result){

console.log(result.data)

})

es6請求  method 請求方式  cache  是否快取是否重新載入

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

#})

vue2 請求

axios({

url:"www.baidu.com?pageStart=18pageSize=3",

method:"get/post",

#如果是get請求的話用params 來傳輸資料或網址列拼接

#params:{

##pageStart:1 ,

pageSize:3

}

如果是post請求的話用data去傳輸資料

data:{

}

##})

實例

#百度跨域請求

#var that=this;

#that.$http.jsonp("

",{wd:this.abc},{jsonp:"cb"}).then(function(result){

#console. log(result.data.s)

})

######360跨域請求###### 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)})###

以上是vue的資料互動形式有哪些的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn