更新记录
0.2.1(2026-06-24) 下载此版本
- 新增:Android 全屏 / 沉浸式模式适配,弹窗不会打破 App 的全屏状态
- 文档:精简重写 README
平台兼容性
uni-app(4.66)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | √ | √ | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| √ | - | - | - | - | - | - | - | - | - | - | - |
其他
| 多语言 | 暗黑模式 | 宽屏模式 |
|---|---|---|
| × | √ | × |
aw-show-modal
Android 原生
showModal插件,替代uni.showModal默认弹窗。
为什么用它
uni.showModal 在 Android 端存在两个明显问题:
- 样式简陋 — 默认弹窗观感粗糙,与 App 整体风格割裂
- 按钮位置互换 — Android 系统弹窗习惯将「确定」放左侧、「取消」放右侧,与 iOS 及用户直觉相反,容易误触
本插件提供 iOS 风格卡片动画与正确的按钮布局(取消在左、确定在右),非 Android 端自动透传 uni.showModal。
平台支持
| 平台 | 实现方式 |
|---|---|
| Android | UTS 原生 Dialog |
| iOS / H5 / 微信小程序 | 透传 uni.showModal |
安装
将 aw-show-modal 目录放入项目 uni_modules/ 即可。
使用方法(与官方uni.showModal一致)
基础用法
import { showModal } from '@/uni_modules/aw-show-modal';
showModal({
title: '提示',
content: '确定要删除吗?',
}).then((res) => {
if (res.confirm) {
console.log('用户点击了确定');
}
});
async / await
const res = await showModal({
title: '删除提示',
content: '确认删除这条数据吗?',
});
if (res.confirm) {
// 执行删除
}
回调风格
showModal({
title: '提示',
content: '确定要删除吗?',
success(res) {
console.log(res.confirm, res.cancel);
},
fail(err) {
console.log(err.errMsg);
},
complete() {
console.log('complete');
},
});
Promise 与回调同时使用
两种风格可同时传入,回调在 Promise resolve 之前触发:
const res = await showModal({
title: '删除提示',
content: '确认删除这条数据吗?',
success(result) {
console.log('success', result);
},
});
输入模式
const res = await showModal({
title: '重命名',
editable: true,
placeholderText: '请输入新名称',
});
if (res.confirm && res.content) {
console.log('用户输入:', res.content);
}
自定义按钮
showModal({
title: '操作确认',
content: '是否保存当前修改?',
cancelText: '放弃',
cancelColor: '#ff3b30',
confirmText: '保存',
confirmColor: '#34c759',
});
仅显示确定按钮
showModal({
title: '通知',
content: '您的版本已更新至最新。',
showCancel: false,
confirmText: '知道了',
});
参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title |
string | '' |
标题 |
content |
string | '' |
正文内容 |
showCancel |
boolean | true |
是否显示取消按钮 |
cancelText |
string | '取消' |
取消按钮文字 |
cancelColor |
string | 主题色 | 取消按钮颜色 |
confirmText |
string | '确定' |
确认按钮文字 |
confirmColor |
string | 主题色 | 确认按钮颜色 |
editable |
boolean | false |
是否显示输入框 |
placeholderText |
string | '' |
输入框占位文字 |
success |
Function | — | 成功回调 |
fail |
Function | — | 失败回调 |
complete |
Function | — | 完成回调 |
返回 Promise,res.confirm / res.cancel 表示点击结果,res.content 为输入内容。
注意事项
- Android 端修改插件源码后,需重新制作自定义基座或云打包
- 同一时刻只允许一个弹窗,重复调用会返回错误
- 如果需要全局使用,只需要在你的全局定义位置引入即可

收藏人数:
下载插件并导入HBuilderX
赞赏(0)
下载 60
赞赏 0
下载 12332966
赞赏 1924
赞赏
京公网安备:11010802035340号