标签:后端 ica test size 状态 默认 div json格式 cat
//fetch get fetch("json/test.json?name=kerwin&age=100").then(res=>{ // console.log(res.json()) //拿到的是 状态码 // return a.text() // 文本格式 return res.json() //json格式 }).then(res=>{ console.log(res.data.films) this.datalist = res.data.films }).catch(err=>{ console.log(err) })
post-1
fetch("json/test.json",{ method:"post", headers:{ "Content‐Type": "application/x‐www‐form‐urlencoded" }, body:"name=kerwin&age=100" //请求体 }).then(res=>res.json()).then(res=>{ console.log(res) })
post-2
fetch("json/test.json",{ method:"post", headers:{ "Content-Type":"application/json" }, body:JSON.stringify({ name:"kerwin", age:100 }) //请求体 }).then(res=>res.json()).then(res=>{ console.log(res) })
fetch("**",{ credentials:"include", method:‘post‘, headers: { "Content‐Type": "application/x‐www‐form‐urlencoded" }, body: "name=kerwin&age=100", }).then(res=>res.json()).then(res=>{console.log(res)});
https://github.com/axios/axios
axios.get("json/test.json?name=kerwin&age=100").then(res=>{ // res.data 才是真正的后端数据 console.log(res.data.data.films) this.datalist= res.data.data.films })
axios.post("json/test.json","name=kerwin&age=100").then(res=>{ console.log(res.data) })
axios.post("json/test.json",{ name:"kerwin", age:100 }).then(res=>{ console.log(res.data) })
标签:后端 ica test size 状态 默认 div json格式 cat
原文地址:https://www.cnblogs.com/wuziqiang/p/13278533.html