目录
学习笔记

axios是干嘛的,axios和ajax哪个好


axios和fetch哪个更好

FetchAPI更好。它被定义在BOM的window对象中,你可以用它来发起对远程资源的请求。

基础axios用法

//依赖于axios对私有ajax进行修改importQsfrom'qs'importaxiosfrom'axios'importrouterfrom'router/index'import{errorPrompt,loading,

closeLoading}from'util/util'exportconststatus={SUCCESS:'',NET_ERR:'',//BIZ_ERR:'',//业务请求异常

NO_AUTH:''}exportfunctionfetch(options){returnnewPromise((resolve,reject)=>{letinstance=axios.create({

baseURL:_API,

timeout:,

headers:{//"tracecode":window.encodeURIComponent(JSON.stringify({"ua":"","cv":"","token":"","os":"","app":"kind","ws":"1*1","pkey":"----"}))

"tracecode":commonBizHeader(isManager(options)),'Content-Type':'application/x-www-form-urlencoded'transformRequest:[function(data){//Dowhateveryouwanttotransformthedataletret=''

for(letitindata){ret+=encodeURIComponent(it)+'='+encodeURIComponent(data[it])+'&'}


写笔记

咨询

您的电子邮箱地址不会被公开。