uni.showloading() 去掉黑色背景框需在app.vue中用css覆盖:uni-toast.uni-toast{background:transparent!important;};若仅隐藏转圈图标,可加参数icon:"none",但黑色背景仍需css处理。

uni.showLoading() 怎么去掉黑色背景框
默认的 uni.showLoading() 会带一个半透明黑色遮罩层(类名 uni-toast),不是 loading 图标本身,而是整个 toast 容器的背景。它无法通过 API 参数关闭,必须靠 CSS 覆盖。
- 在
App.vue的<style></style>块中添加:uni-toast.uni-toast { background: transparent !important; } - 注意加
!important,否则被 uni-app 内置样式覆盖 - 如果只希望影响 loading、不影响其他 toast(如 success/error),可限定更精确的选择器:
uni-toast.uni-toast[aria-label="loading"],但兼容性略差,推荐先用通用方案
怎么让 uni.showLoading() 不显示转圈图标
图标由 icon 参数控制,默认值是 "loading",设为 "none" 即可隐藏转圈,只留文字。
- 调用时写成:
uni.showLoading({ title: "加载中", icon: "none" }) - 注意:即使设了
icon: "none",黑色背景仍存在,仍需上一步的 CSS 覆盖 - 不推荐完全移除
title,否则可能触发空提示导致 UI 异常或白屏
离线打包后 APP 启动卡在 loading 页关不掉
这不是 uni.showLoading() 的问题,而是原生层 splashscreen 没正确关闭,尤其在 Android 14/15 和部分模拟器(如 android status)上表现明显。manifest.json 的配置对离线打包基本无效。
- 必须在
onLaunch中主动调用plus.navigator.closeSplashscreen() - 延迟不能太长,建议
setTimeout(() => plus.navigator.closeSplashscreen(), 100),超过 6s 系统会强制关闭,但期间 JS 可能已阻塞 - 确保
plus对象可用:仅在#ifdef APP-PLUS块内调用,且不能放在异步回调里(比如uni.getSystemInfo成功后才调) - 如果首页有网络请求或路由守卫逻辑,务必确认它们没抛错或没陷入 pending 状态,否则
onLaunch后续流程卡住,splashscreen 就不会被关闭
为什么删了 static/splash.png 还有加载动画
删除该图片只影响「启动图」(splash image),和运行时调用 uni.showLoading() 或原生 splashscreen 的行为完全无关。两者是不同机制:
-
static/splash.png→ 控制 APP 启动瞬间那张静态图(冷启动画面) -
uni.showLoading()→ 页面运行中手动触发的 JS 层 loading 提示 -
plus.navigator.closeSplashscreen()→ 关闭原生层启动动画(含雪花、渐隐等)
三者混用容易误判根源。真要彻底“无 loading”,得分别处理这三层,且优先级是:原生 splashscreen > JS loading 提示 > 静态启动图。











