1.1.2 • Published 2 years ago
czp-utils v1.1.2
introduce
提供一些公共方法:防抖、节流、深拷贝、自定义事件总线、获取页面 url 全部参数、身份证校验、获取当前年月日、格式化资金数字
install
npm install czp-utils
usage
import { axiosWrapper } from 'czp-utils'
const fn = async () => {
// 业务1 使用err判断
const { err, res } = await axiosWrapper(Axios.get('xxx1'));
if (err) {
alert(err);
} else {
console.log(res);
}
// 业务2 使用res判断 使用这种判断的时候注意你的返回结果是不是有为null的时候
const { err, res } = await toAsyncAwait(Axios.get('xxx2'));
if (res) {
console.log(res);
} else {
alert(err);
}
// 业务三不管错误
const { res } = await toAsyncAwait(Axios.get('xxx3'));
if (res) {
console.log(res);
}
}