vue3 axios 请求全局loading
vue3 axios 请求全局loading
·
基于vben的loading组件,对全局loading进行处理,优化用户体验
import { useLoading } from '/@/components/Loading';
// 请求个数
let requestNumber = 0
const [openFullLoading, closeFullLoading] = useLoading({
tip: '加载中...',
});
// 开启全局loading
const openLoading = () => {
requestNumber++
if (requestNumber === 1) {
openFullLoading()
}
}
// 关闭全局loading
const closeLoading = () => {
requestNumber--
if (requestNumber === 0) {
closeFullLoading()
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)