fetch
- 因为XMLHttpRequest配置和调用方法非常混乱,而且基于事件的异步模型书写不友好。
- 浏览器自带。
- 兼容不好:兼容包
https://github.com/camsong/fetch-ie8
- fetch请求默认不带cookie,需要设置fetch(url,{credntials:‘include’})
//text.json
{
'name':'silly',
'age':'20',
"location":"zhengzhou"
}
const app = new Vue({
el:'#box',
data:{
list:[],
},
methods:{
//get请求方式
doThatGet:function(){
fetch("./text.json?name=silly")
.then(res=>res.json())
.then(res=>{
concoloe.log(res)})
},
//p