简体中文
显示消息提示框
名称 | 类型 | 必填 | 默认值 | 描述 | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ShowToastOptions | 是 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
errCode | 1 | 1001 | 是 | - | 错误码 - 1 撤销 - 1001 请求参数非法 |
errSubject | string | 是 | - | 统一错误主题(模块)名称 |
data | any | null | 否 | - | 错误信息中包含的数据 |
cause | Error | null | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
Template
Script
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap" id="btn-toast-default" >点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError" id="btn-toast-errorIcon">点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap" id="btn-toast-duration">点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap" id="btn-toast-loading">点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<!-- #ifdef APP -->
<button class="uni-btn-v" type="default" @tap="toast5Tap" id="btn-toast-postion-bottom">点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast" id="btn-toast-hide">点击隐藏toast</button>
</view>
<text>{{exeRet}}</text>
</view>
</view>
</template>
Android | iOS | web |
---|---|---|
3.9.0 | 4.11 | 4.0 |
position
参数特别说明如果没有设置 position
字段,uni.showToast
会采用应用弹窗方案,即弹窗与页面生命周期绑定。 页面关闭时,当前页面弹出的所有弹窗都会被自动取消。
如果设置了position
字段,uni.showToast
会采用系统弹窗方案,即弹窗与页面无绑定关系。 页面关闭后,弹出中的/等待弹出的Toast
会继续展示。
系统弹窗在部分系统(比如 MIUI,Google)可能会有应用图标前缀。
系统弹窗在部分系统(比如 鸿蒙 4.0以上)可能不支持顶部和居中展示。
显示 loading 提示框, 需主动调用 uni.hideLoading 才能关闭提示框。
名称 | 类型 | 必填 | 默认值 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ShowLoadingOptions | 是 | - | |||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
errCode | 1 | 1001 | 是 | - | 错误码 - 1 撤销 - 1001 请求参数非法 |
errSubject | string | 是 | - | 统一错误主题(模块)名称 |
data | any | null | 否 | - | 错误信息中包含的数据 |
cause | Error | null | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
Template
Script
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示透明蒙层-屏蔽点击事件</view>
<switch :checked="maskSelect" @change="maskChange" />
</view>
<view class="uni-padding-wrap">
<view class="uni-title uni-common-mt">
<text class="uni-title-text"> 设置标题 </text>
</view>
</view>
<view class="uni-list uni-common-pl">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="primary" @click="showLoading">显示 loading 提示框</button>
<button class="uni-btn-v" @click="hideLoading">隐藏 loading 提示框</button>
<text>为方便演示,loading弹出3秒后自动关闭</text>
</view>
</view>
</view>
</template>
Android | iOS | web |
---|---|---|
3.9.0 | 4.11 | 4.0 |
显示模态弹窗,可以只有一个确定按钮,也可以同时有确定和取消按钮。类似于一个API整合了 html 中:alert、confirm。
名称 | 类型 | 必填 | 默认值 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ShowModalOptions | 是 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
confirm | boolean | 是 | - | 为 true 时,表示用户点击了确定按钮 |
cancel | boolean | 是 | - | 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) |
content | string | null | 否 | - | editable 为 true 时,用户输入的文本 |
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
errCode | 1 | 1001 | 是 | - | 错误码 - 1 撤销 - 1001 请求参数非法 |
errSubject | string | 是 | - | 统一错误主题(模块)名称 |
data | any | null | 否 | - | 错误信息中包含的数据 |
cause | Error | null | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示取消按钮</view>
<switch :checked="showCancelSelect" @change="showCancelChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制取消文案</view>
<switch :checked="cancelTextSelect" @change="cancelTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">定制确认文案</view>
<switch :checked="confirmTextSelect" @change="confirmTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否显示输入框</view>
<switch :checked="editableSelect" @change="editableChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否定制输入提示词</view>
<switch :checked="placeholderTextSelect" @change="placeholderTextChange" />
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="modalTap" id="btn-modal-show">
modal测试
</button>
</view>
<text>{{ exeRet }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
Android | iOS | web |
---|---|---|
3.9.0 | 4.11 | 4.0 |
从底部向上弹出操作菜单
名称 | 类型 | 必填 | 默认值 | 描述 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ShowActionSheetOptions | 是 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
tapIndex | number | null | 否 | - | 用户点击的按钮,从上到下的顺序,从0开始 |
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
errCode | 1 | 1001 | 是 | - | 错误码 - 1 撤销 - 1001 请求参数非法 |
errSubject | string | 是 | - | 统一错误主题(模块)名称 |
data | any | null | 否 | - | 错误信息中包含的数据 |
cause | Error | null | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
errMsg | string | 是 | - | - |
itemList,即actionsheet的列表项,在app和小程序上最多6项,超出会报错。在web上超出不报错,列表区变为可滚动。
Template
Script
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line': ''" :value="item.value" :checked="index === current">
{{item.name}}
</radio>
</radio-group>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义itemColor</view>
<switch :checked="itemColorCustom" @change="itemColorChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">超长文本和空文本item</view>
<switch :checked="itemContentLarge" @change="itemContentLargeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">超过6个item</view>
<switch :checked="itemNumLargeSelect" @change="itemNumLargeChange" />
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="actionSheetTap" id="btn-action-sheet-show">弹出action sheet</button>
</view>
</view>
</view>
</template>
Android | iOS | web |
---|---|---|
3.9.0 | 4.11 | 4.0 |
名称 | 类型 | 必备 | 默认值 | 描述 |
---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |