# 弹窗 - [导入模块](#zh-cn_topic_0000001059340516_s1fada83813e64efcbc67e970ced86588) - [权限列表](#zh-cn_topic_0000001059340516_section11257113618419) - [prompt.showToast\(OBJECT\)](#zh-cn_topic_0000001059340516_sc34d255befcf467dab069802dc9e54d8) - [prompt.showDialog\(OBJECT\)](#zh-cn_topic_0000001059340516_sc6babedb391e4de9af1189ebc9ff5e69) ## 导入模块 ``` import prompt from '@system.prompt'; ``` ## 权限列表 无 ## prompt.showToast\(OBJECT\) 显示文本弹窗。 - 参数

参数名

类型

必填

说明

message

string

显示的文本信息。

duration

number

默认值1500ms,建议区间:1500ms-10000ms。

说明:

若小于1500ms则取默认值,最大取值为10000ms。

[bottom]5+

<length>

设置弹窗边框距离屏幕底部的位置。

- 示例 ``` prompt.showToast({ message: 'Message Info', duration: 2000, }); ``` ## prompt.showDialog\(OBJECT\) 在页面内显示对话框。 - 参数

参数名

类型

必填

说明

title

string

标题文本。

message

string

内容文本。

buttons

Array

对话框中按钮的数组,结构为:{text:'button', color: '#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。

success

Function

接口调用成功的回调函数,返回值如success返回值所示。

cancel

Function

取消调用此接口的回调函数。

complete

Function

弹框退出时的回调函数。

success返回值:

参数名

类型

说明

index

number

选中按钮在buttons数组中的索引。

- 示例 ``` prompt.showDialog({ title: 'Title Info', message: 'Message Info', buttons: [ { text: 'button', color: '#666666', }, ], success: function(data) { console.log('dialog success callback,click button : ' + data.index); }, cancel: function() { console.log('dialog cancel callback'); }, }); ```