更新记录
1.0.02(2024-03-30)
暴露方法
1.0.01(2024-03-25)
1.0.01
1.0.0(2024-03-25)
更新readme
查看更多平台兼容性
Vue2 | Vue3 |
---|---|
√ | √ |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
app-vue app-nvue | √ | √ | √ | √ | √ | √ |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 |
---|---|---|---|
√ | √ | √ | √ |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | √ | √ | √ | √ |
loading-stack
loadingStack 解决 uni.showLoading 和 uni.showToast 不能 指定消除的特定loading的问题。
实现原理
利用 uni.showToast 实现,全局设置 stack 栈 记录运行的loading,最近加入的优先显示。
提示
如果你的项目是ts项目,在根目录存在tsconfig.json,写代码时就会有提示。
//tsconfig.json案例
{
"compilerOptions": {
"target": "es2015",
"module": "ESNext",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true
}
}
使用案例
//在main.js中引入即可
import '@/uni_modules/loading-stack/main'
使用介绍:
//创建一个loading 不填有默认加载弹窗,返回添加的loading
uni.$showStackLoading(options?:TLoading): Loading;
//隐藏一个loading 不填默认清除栈顶loading,返回清除的loading
uni.$hideStackLoading(loading?: Loading): Loading;
//清除所有弹窗,如果传入弹窗参数,则弹出该弹窗。并返回该弹窗
uni.$hideAllStackLoading(options?:TLoading): Loading | null;
type TLoading = {
title?:string,
mask?:boolean, //默认为true
image?:string,
position?:"top" | "center" | "bottom",
icon?:"success" | "fail" | "loading" | "error" | "none",
duration?:number, // 创建的弹窗没填写时间则默认永久(1000*60*60*24)。
success?:(loading:Loading)=>any; // 时间到了自然死亡 由duration控制
fail?:(loading:Loading)=>any; //时间没到被强制杀死 比如调用uni.$hideStackLoading和uni.$hideAllStackLoading
final?:(loading:Loading)=>any; //不管如何关闭时都会触发触发时间在success/fail之后
}