---
title: "Ext.window.MessageBox"
description: "xtype 为 messagebox 的 Ext JS 原生组件参考。"
---

> Documentation Index
> Fetch the complete documentation index at: https://ag.879818327.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Ext.window.MessageBox

源码定义：`ext-all-debug.js:95512`。分类：容器、面板与窗口。

## 创建示例

```javascript
var component = Ext.create("Ext.window.MessageBox", {
  xtype: "messagebox",
  ariaRole: 'alertdialog',
  buttonIds: [,
  buttonText: {,
  CANCEL: 8,
  renderTo: Ext.getBody()
});
```

## 属性

| 属性 | 类型 | 默认值 | 说明 | 配置示例 |
| --- | --- | --- | --- | --- |
| `ariaRole` | `String` | `'alertdialog'` | 组件在辅助技术中的 ARIA 角色。 | `ariaRole: 'alertdialog'` |
| `buttonIds` | `Array` | `[` | 配置组件的 `buttonIds` 选项。 | `buttonIds: [` |
| `buttonText` | `Object` | `{` | 配置组件的 `buttonText` 选项。 | `buttonText: {` |
| `CANCEL` | `Number` | `8` | 配置组件的 `CANCEL` 选项。 | `CANCEL: 8` |
| `constrain` | `Boolean` | `true` | 控制是否启用 `constrain` 行为。 | `constrain: true` |
| `defaultMaxHeight` | `Number` | `500` | 配置组件的 `defaultMaxHeight` 选项。 | `defaultMaxHeight: 500` |
| `defaultMaxWidth` | `Number` | `600` | 配置组件的 `defaultMaxWidth` 选项。 | `defaultMaxWidth: 600` |
| `defaultMinHeight` | `Number` | `110` | 配置组件的 `defaultMinHeight` 选项。 | `defaultMinHeight: 110` |
| `defaultMinWidth` | `Number` | `250` | 配置组件的 `defaultMinWidth` 选项。 | `defaultMinWidth: 250` |
| `defaultTextHeight` | `Number` | `75` | 配置组件的 `defaultTextHeight` 选项。 | `defaultTextHeight: 75` |
| `ERROR` | `Mixed` | `Ext.baseCSSPrefix + 'message-box-error'` | 配置组件的 `ERROR` 选项。 | `ERROR: Ext.baseCSSPrefix + 'message-box-error'` |
| `hideMode` | `String` | `'offsets'` | 配置组件的 `hideMode` 选项。 | `hideMode: 'offsets'` |
| `iconHeight` | `Number` | `35` | 配置组件的 `iconHeight` 选项。 | `iconHeight: 35` |
| `iconWidth` | `Number` | `50` | 配置组件的 `iconWidth` 选项。 | `iconWidth: 50` |
| `INFO` | `Mixed` | `Ext.baseCSSPrefix + 'message-box-info'` | 配置组件的 `INFO` 选项。 | `INFO: Ext.baseCSSPrefix + 'message-box-info'` |
| `layout` | `Object` | `{` | 容器对子组件进行排布的布局配置。 | `layout: {` |
| `maxHeight` | `Object/null` | `null` | 配置 `maxHeight` 限制值。 | `maxHeight: null` |
| `maxWidth` | `Object/null` | `null` | 配置 `maxWidth` 限制值。 | `maxWidth: null` |
| `minHeight` | `Object/null` | `null` | 配置 `minHeight` 限制值。 | `minHeight: null` |
| `minProgressWidth` | `Number` | `250` | 配置 `minProgressWidth` 限制值。 | `minProgressWidth: 250` |
| `minPromptWidth` | `Number` | `250` | 配置 `minPromptWidth` 限制值。 | `minPromptWidth: 250` |
| `minWidth` | `Object/null` | `null` | 配置 `minWidth` 限制值。 | `minWidth: null` |
| `NO` | `Number` | `4` | 配置组件的 `NO` 选项。 | `NO: 4` |
| `OK` | `Number` | `1` | 配置组件的 `OK` 选项。 | `OK: 1` |
| `OKCANCEL` | `Number` | `9` | 配置组件的 `OKCANCEL` 选项。 | `OKCANCEL: 9` |
| `QUESTION` | `Mixed` | `Ext.baseCSSPrefix + 'message-box-question'` | 配置组件的 `QUESTION` 选项。 | `QUESTION: Ext.baseCSSPrefix + 'message-box-question'` |
| `resizable` | `Boolean` | `false` | 控制是否启用 `resizable` 行为。 | `resizable: false` |
| `shrinkWrapDock` | `Boolean` | `true` | 控制是否启用 `shrinkWrapDock` 行为。 | `shrinkWrapDock: true` |
| `stayOnTop` | `Boolean` | `true` | 控制是否启用 `stayOnTop` 行为。 | `stayOnTop: true` |
| `title` | `String` | `'&#160;'` | 面板或窗口显示的标题。 | `title: '&#160;'` |
| `titleText` | `Object` | `{` | 配置组件的 `titleText` 选项。 | `titleText: {` |
| `WARNING` | `Mixed` | `Ext.baseCSSPrefix + 'message-box-warning'` | 配置组件的 `WARNING` 选项。 | `WARNING: Ext.baseCSSPrefix + 'message-box-warning'` |
| `YES` | `Number` | `2` | 配置组件的 `YES` 选项。 | `YES: 2` |
| `YESNO` | `Number` | `6` | 配置组件的 `YESNO` 选项。 | `YESNO: 6` |
| `YESNOCANCEL` | `Number` | `14` | 配置组件的 `YESNOCANCEL` 选项。 | `YESNOCANCEL: 14` |

## 方法

| 方法 | 参数 | 说明 | 调用示例 |
| --- | --- | --- | --- |
| `makeButton` | `btnIdx` | 处理 `makeButton` 操作。 | `component.makeButton(...)` |
| `btnCallback` | `btn` | 处理 `btnCallback` 操作。源码涉及 `hide()`、`userCallback()`。 | `component.btnCallback(...)` |
| `hide` | `` | 隐藏组件。 执行时会保留父类默认行为、更新 `minWidth`、`defaultMinWidth` 状态。源码涉及 `removeCls()`、`callParent()`。 | `component.hide()` |
| `initComponent` | `cfg` | 初始化组件及其子项。 执行时会保留父类默认行为、更新 `title`、`iconCls` 状态。源码涉及 `makeButton()`、`on()`、`callParent()`。 | `component.initComponent(...)` |
| `onClose` | `` | 处理 `close` 回调。源码涉及 `btnCallback()`。 | `component.onClose()` |
| `onEnter` | `me, k, e` | 处理 `enter` 回调。 | `component.onEnter(...)` |
| `onPromptKey` | `textField, e` | 处理 `promptKey` 回调。 | `component.onPromptKey(...)` |
| `reconfigure` | `cfg` | 重新配置当前组件。 执行时会更新 `cfg`、`minWidth` 状态。源码涉及 `updateButtonText()`、`setTitle()`、`setIconCls()`、`setWidth()`。 | `component.reconfigure(...)` |
| `updateButtonText` | `` | 更新 `buttonText`。 | `component.updateButtonText()` |
| `show` | `cfg` | 显示组件。 执行时会保留父类默认行为、更新 `preventFocusOnActivate`、`hidden` 状态。源码涉及 `reconfigure()`、`addCls()`、`query()`、`callParent()`。 | `component.show(...)` |
| `onShow` | `` | 处理 `show` 回调。 执行时会保留父类默认行为。源码涉及 `callParent()`、`center()`。 | `component.onShow()` |
| `updateText` | `text` | 更新 `text`。 | `component.updateText(...)` |
| `setIcon` | `icon, width, height` | 设置 `icon`。 执行时会更新 `messageIconCls` 状态。 | `component.setIcon(...)` |
| `updateProgress` | `value, progressText, msg` | 更新 `progress`。源码涉及 `updateText()`。 | `component.updateProgress(...)` |
| `onEsc` | `` | 处理 `esc` 回调。 执行时会保留父类默认行为。源码涉及 `callParent()`。 | `component.onEsc()` |
| `confirm` | `cfg, msg, fn, scope` | 处理 `confirm` 操作。源码涉及 `show()`。 | `component.confirm(...)` |
| `prompt` | `cfg, msg, fn, scope, multiline, value` | 处理 `prompt` 操作。源码涉及 `show()`。 | `component.prompt(...)` |
| `wait` | `cfg, title, config` | 等待当前组件。源码涉及 `show()`。 | `component.wait(...)` |
| `alert` | `cfg, msg, fn, scope` | 处理 `alert` 操作。源码涉及 `show()`。 | `component.alert(...)` |
| `progress` | `cfg, msg, progressText` | 处理 `progress` 操作。源码涉及 `show()`。 | `component.progress(...)` |

## 事件

源码中未找到该组件自身注册的事件；可监听继承事件。

Source: https://ag.879818327.xyz/ext/layout/window-messagebox/index.mdx
