fetch的用法
发表于:2023-09-07 08:14:18浏览:147次
1.GET请求
fetch('/index.php/Product/Index/getRoleByPano?id='+id,{
method:'get',
headers:{
'Content-Type':'application/json'
}
})
.then(res => res.json())
.then( ({data:data}) =>{
console.log(data);
})
2.POST请求
fetch('/Admin/Pay/create',{
method:'POST',
body:JSON.stringify({gold:this.price}),
headers:{
'Content-Type':'application/json'
}
})
.then(res => res.json())
.then( (res) =>{
let url = "http://hh.maoyingkeji.com/index.php/pay/id/"+res.info;
window.open(url);
})
栏目分类全部>