从表达提交开始说起:
axios别名提交
url=“api接口“
params={user:”",pass:""}
header={
headers:{“Content-Type”:“application/json”}
}
axios.get(url,params,header)
axios.post(url,qs.stringify(data),header)
get提交 设置头文件 headers:{“Content-Type”:“application/json”}默认的,连接在url后面
post提交 content-type:application/x-www-form-urlencoded 提交不是在url路径后面,而是包含body内容里面,所以需要设置rul编码。同时需要把提交的数据编码成字符串,npm install qs ,import qs from ‘qs’,调用qs.stringify(data)转码,
file提交 设置content-type:multipart/form-data
axios文件提交
input type=“file” @change=“change”
change(e){
let a=e.target.files[0]
let f=new FormData()
f.append(“file”,a);
f.get(“file”)
}
php采用$_FILES全局变量获取。