class Ajax{ constructor() { this.ajax = new XMLHttpRequest () } /** * * @param{*}params * { * 请求的网址 url:"", * * 请求的参数 data:{ * (对象) id:1, * page:2 * }, * * 请求头 header:{ * (对象) 'Content-Type':'application/json;charset=UTF-8' * }, * * 请求成功的回调 success:(res)=>{}, * (方法) * * 请求失败的回调 erro:(err)=>{不同地方的错误提示也不一样,可以不用但必须要有}, * } */ get(params){ ajax.open("GET","http://localhost") } post(){} }