ajax eS6

const axios=require(‘axios’)
class ajax {
constructor(url,data){
this.url=url;
this.data=data;
}
init(){
}
event(callback){
console.log(this.data)
axios({
method:“post”,
url:this.url,
data:this.data,
headers:{“IdentityToken”:window.sessionStorage.getItem(“IdentityToken”)},
dataType:“json”
}).then(res=>{
return callback(res.data)
})
}

}

var ajaxs={
Axo:ajax
}
export default ajaxs

es6模块封装

你可能感兴趣的:(ajax,es6)