qwq-luyao
v2.0.1
Published
## 使用方法
Downloads
5
Readme
luyao_ajax 教程
使用方法
安装luyao_ajax包
npm i -S luyao_ajax
引入包
const luyo_ajax = require("luyao_ajax");
基础用法
//基础用法类似 jquery luyao.ajax( option ) 接收一个参数 option 作为一个复合参数可接受格式 { url : "", // 请求路径 method : 'get' // 默认get不区分大小写, data : {}, // 需要传递的参数 success : function(data){ // 请求成功回调函数 console.log(data) // 数据 }, err : function(data){ // 请求失败回调函数 console.log(err) } }
Promise 接收参数
request({ url : "http://localhost:1111/get", method : 'get' // 默认get不区分大小写, data : { } }).then(data=>{ console.log(data) // 返回的数据 })
抛出错误
request({ ...., success : function(data){}, err : function(err){} // 错误抛出 }).then(data=>{ console.log(data) // 返回的数据 }).catch(data=>{}) //promise 错误
tips:green_heart: 嘤嘤嘤