## 基本用法 打开 Alert ```html ``` ## 返回 Promise 打开 alert ```html ``` 打开 confirm ```html ``` 打开 prompt ```html ``` 打开 Message Box ```html ``` ## 更多配置项 打开 Message Box ```html ``` ## 全局方法 element 为 Vue.prototype 添加了如下全局方法:$msgbox, $alert, $confirm 和 $prompt。因此在 vue instance 中可以采用本页面中的方式调用 `MessageBox`。 ## 单独引用 单独引入 `MessageBox`: ```javascript import { MessageBox } from 'element-ui'; ``` 对应于上述四个全局方法的调用方法依次为:MessageBox, MessageBox.alert, MessageBox.confirm 和 MessageBox.prompt。 ## API | 参数 | 说明 | 类型 | 可选值 | 默认值 | |---------- |-------------- |---------- |-------------------------------- |-------- | | title | 标题 | string | | | | message | 消息内容 | string | | | | type | 消息类型 | string | 'success', 'info', 'warning', 'error' | | | showCancelButton | 是否显示取消按钮 | boolean | | false(以 confirm 和 prompt 方式调用时为 true) | | showConfirmButton | 是否显示确定按钮 | boolean | | true | | cancelButtonText | 取消按钮的文本内容 | string | | '取消' | | confirmButtonText | 确定按钮的文本内容 | string | | '确定' | | cancelButtonClass | 取消按钮的自定义类名 | string | | | | confirmButtonClass | 确定按钮的自定义类名 | string | | | | showInput | 是否显示输入框 | boolean | | false(以 prompt 方式调用时为 true)| | inputValue | 输入框的值 | string | | | | inputPlaceholder | 输入框的占位符 | string | | | | inputPattern | 输入框的校验表达式 | regexp | | | | inputValidator | 输入框的校验函数。若返回一个字符串, 则返回结果会被赋值给 inputErrorMessage | function | | | | inputErrorMessage | 校验未通过时的提示文本 | string | | '输入的数据不合法!' |