Teal TealUI

消息框ui/messageBox

基本用法
样式
API
MessageBox 类

基本用法

<button onclick="MessageBox.alert('警告')">警告</button>
<button onclick="MessageBox.confirm('确认删除吗?', '标题', function(){ alert('点击了确定') })">确认框</button>
<button onclick="MessageBox.prompt('请输入文字', '标题', function(text){ alert(text) })">输入框</button>

样式

<div class="x-dialog" style="display: none;">
    <section class="x-panel">
        <header class="x-panel-header">
            <a class="x-close x-dialog-close" href="javascript:;">✖</a>
            <h5>顶部</h5>
        </header>
        <div class="x-panel-icon x-icon x-tip-warning">⚠</div>
        <div class="x-panel-body">
            内容
        </div>
        <div class="x-panel-buttons">
            <button class="x-button x-button-primary">确定</button>
            <button class="x-button">取消</button>
        </div>
    </section>
</div>

API

MessageBox 类

继承自:Dialog

表示一个消息框。

字段 类型 描述 继承自
⮞ onOk : () => boolean | void

点击确定事件。

function

点击确定事件。

—
⮞ onCancel : () => boolean | void

点击取消事件。

function

点击取消事件。

—
⮞ icon : "error" | "warning" | "info" | "success" | "confirm"

图标。

string

图标。

—
⮞ buttons : { [content: string]: boolean | (() => void); }

按钮。

object

按钮。

—
⮞ primaryButton : number

主按钮。

number

主按钮。

—
⮞ header : HTMLElement

头部。

继承自

Dialog

HTMLElement

头部。

Dialog
⮞ title : NodeLike

标题。

继承自

Dialog

NodeLike

标题。

Dialog
⮞ hideClose : boolean

是否可关闭。

继承自

Dialog

boolean

是否可关闭。

Dialog
⮞ body : HTMLElement

(已覆盖)(只读)获取用于包含子控件和节点的根元素。

继承自

Control

HTMLElement

(已覆盖)(只读)获取用于包含子控件和节点的根元素。

Control
⮞ animation : ToggleAnimation

切换显示的动画。

继承自

Dialog

ToggleAnimation

切换显示的动画。

Dialog
⮞ target : HTMLElement

切换显示的动画目标。

继承自

Dialog

HTMLElement

切换显示的动画目标。

Dialog
⮞ onShow : (sender: MessageBox) => void

显示对话框事件。

继承自

Dialog

function

显示对话框事件。

Dialog
⮞ onBeforeClose : (sender: MessageBox) => boolean | void

即将关闭对话框事件。

继承自

Dialog

function

即将关闭对话框事件。

Dialog
⮞ onClose : (sender: MessageBox) => void

关闭对话框事件。

继承自

Dialog

function

关闭对话框事件。

Dialog
⮞ draggable : boolean

是否可拖动。

继承自

Dialog

boolean

是否可拖动。

Dialog
⮞ readyState : ControlState

获取当前控件的渲染状态。

继承自

Control

ControlState

获取当前控件的渲染状态。

Control
⮞ elem : HTMLElement

关联的元素。

继承自

Control

HTMLElement

关联的元素。

Control
⮞ vNode : VNode

(保护的)获取当前控件关联的虚拟节点。

继承自

Control

VNode

(保护的)获取当前控件关联的虚拟节点。

Control
⮞ sourceVNode : VNode

获取创建该控件使用的源虚拟节点。

继承自

Control

VNode

获取创建该控件使用的源虚拟节点。

Control
⮞ alwaysUpdate : boolean

控件是否使用主动更新模式。

继承自

Control

boolean

控件是否使用主动更新模式。

Control
⮞ duration : number = 200

渐变的持续毫秒数。如果为 0 则不使用渐变。

继承自

Control

number

渐变的持续毫秒数。如果为 0 则不使用渐变。

Control
⮞ class : string

CSS 类名。

继承自

Control

string

CSS 类名。

Control
⮞ hidden : boolean

是否隐藏。

继承自

Control

boolean

是否隐藏。

Control
⮞ style : string | { [key: string]: string | number; }

控件样式。

继承自

Control

string | object

控件样式。

Control
⮞ id : string

控件序号。

继承自

Control

string

控件序号。

Control
⮞ content : NodeLike

控件内容。

继承自

Control

NodeLike

控件内容。

Control
⮞ onSelectStart : (e: Event, sender: MessageBox) => void function

选择开始事件。

Control
⮞ onClick : (e: MouseEvent, sender: MessageBox) => void function

点击事件。

Control
⮞ onAuxClick : (e: MouseEvent, sender: MessageBox) => void function

中键点击事件。

Control
⮞ onDblClick : (e: MouseEvent, sender: MessageBox) => void function

双击事件。

Control
⮞ onContextMenu : (e: PointerEvent, sender: MessageBox) => void function

右键菜单事件。

Control
⮞ onMouseDown : (e: MouseEvent, sender: MessageBox) => void function

鼠标按下事件。

Control
⮞ onMouseUp : (e: MouseEvent, sender: MessageBox) => void function

鼠标按上事件。

Control
⮞ onMouseOver : (e: MouseEvent, sender: MessageBox) => void function

鼠标移入事件。

Control
⮞ onMouseOut : (e: MouseEvent, sender: MessageBox) => void function

鼠标移开事件。

Control
⮞ onMouseEnter : (e: MouseEvent, sender: MessageBox) => void function

鼠标进入事件。

Control
⮞ onMouseLeave : (e: MouseEvent, sender: MessageBox) => void function

鼠标离开事件。

Control
⮞ onMouseMove : (e: MouseEvent, sender: MessageBox) => void function

鼠标移动事件。

Control
⮞ onWheel : (e: WheelEvent, sender: MessageBox) => void function

鼠标滚轮事件。

Control
⮞ onScroll : (e: UIEvent, sender: MessageBox) => void function

滚动事件。

Control
⮞ onTouchStart : (e: TouchEvent, sender: MessageBox) => void function

触摸开始事件。

Control
⮞ onTouchMove : (e: TouchEvent, sender: MessageBox) => void function

触摸移动事件。

Control
⮞ onTouchEnd : (e: TouchEvent, sender: MessageBox) => void function

触摸结束事件。

Control
⮞ onTouchCancel : (e: TouchEvent, sender: MessageBox) => void function

触摸撤销事件。

Control
⮞ onPointerEnter : (e: PointerEvent, sender: MessageBox) => void function

指针进入事件。

Control
⮞ onPointerLeave : (e: PointerEvent, sender: MessageBox) => void function

指针离开事件。

Control
⮞ onPointerOver : (e: PointerEvent, sender: MessageBox) => void function

指针移入事件。

Control
⮞ onPointerOut : (e: PointerEvent, sender: MessageBox) => void function

指针移开事件。

Control
⮞ onPointerDown : (e: PointerEvent, sender: MessageBox) => void function

指针按下事件。

Control
⮞ onPointerMove : (e: PointerEvent, sender: MessageBox) => void function

指针移动事件。

Control
⮞ onPointerUp : (e: PointerEvent, sender: MessageBox) => void function

指针松开事件。

Control
⮞ onPointerCancel : (e: PointerEvent, sender: MessageBox) => void function

指针取消事件。

Control
⮞ onGotPointerCapture : (e: PointerEvent, sender: MessageBox) => void function

指针开始捕获事件。

Control
⮞ onLostPointerCapture : (e: PointerEvent, sender: MessageBox) => void function

指针停止捕获事件。

Control
方法 描述 继承自
⮞ ok()():void

点击确定按钮。

返回值

类型:void

点击确定按钮。

—
⮞ cancel()():void

点击取消按钮。

返回值

类型:void

点击取消按钮。

—
⮞ handleCloseClick()():void

(保护的)当点击关闭按钮后执行。

返回值

类型:void

继承自

Dialog

(保护的)(已覆盖)当点击关闭按钮后执行。

Dialog
⮞ render()():VNode

(保护的)

返回值

类型:VNode

继承自

Control

(保护的)当被子类重写时负责返回当前控件的虚拟节点。

Control
⮞ init()():void

(保护的)

返回值

类型:void

继承自

Control

(保护的)当被子类重写时负责在关联元素后初始化当前控件。

Control
⮞ show(...)(target?:HTMLElement):void

显示当前对话框。

参数 类型 描述 默认值
target HTMLElement —

返回值

类型:void

继承自

Dialog

显示当前对话框。

Dialog
⮞ close(...)(target?:HTMLElement):void

关闭当前对话框。

参数 类型 描述 默认值
target HTMLElement —

返回值

类型:void

继承自

Dialog

关闭当前对话框。

Dialog
⮞ uninit()():void

(保护的)当被子类重写时负责在元素被取消关联前取消初始化当前控件。

返回值

类型:void

继承自

Control

(保护的)当被子类重写时负责在元素被取消关联前取消初始化当前控件。

Control
⮞ update()():void

重新渲染当前控件。

返回值

类型:void

继承自

Control

重新渲染当前控件。

Control
⮞ layout(changes)(changes:Changes):void

重新布局当前控件。

参数 类型 描述 默认值
changes* Changes —

返回值

类型:void

继承自

Control

重新布局当前控件。

Control
⮞ invalidate()():void

使当前控件无效并在下一帧重新渲染。

返回值

类型:void

继承自

Control

使当前控件无效并在下一帧重新渲染。

Control
⮞ renderTo(parent, ...)(parent:Control | Node, refChild?:Control | Node):void

将当前控件渲染到指定的父控件或节点。

参数 类型 描述 默认值
parent* Control | Node —
refChild Control | Node —

返回值

类型:void

继承自

Control

将当前控件渲染到指定的父控件或节点。

Control
⮞ find(selector)(selector:string):Control | HTMLElement

在当前控件查找指定的子控件或节点。

参数 类型 描述 默认值
selector* string —

返回值

类型:Control | HTMLElement

返回子控件或节点。如果找不到则返回 null。

继承自

Control

在当前控件查找指定的子控件或节点。

Control
⮞ query(selector)(selector:string):(Control | HTMLElement)[]

在当前控件查找匹配的所有子控件或节点。

参数 类型 描述 默认值
selector* string —

返回值

类型:(Control | HTMLElement)[]

返回子控件或节点列表。

继承自

Control

在当前控件查找匹配的所有子控件或节点。

Control
⮞ MessageBox.show(content, ...)(content:NodeLike, title?:NodeLike, buttons?:object, icon?:string, onOk?:function, onCancel?:function):MessageBox

显示一个消息框。

参数 类型 描述 默认值
content* NodeLike —
title NodeLike "提示"
buttons { [content: string]: boolean | (() => void); } { 确定: true }
icon "error" | "warning" | "info" | "success" | "confirm" —
onOk () => boolean | void —
onCancel () => boolean | void —

返回值

类型:MessageBox

显示一个消息框。

—
⮞ MessageBox.alert(content, ...)(content:NodeLike, title?:NodeLike, onOk?:function):MessageBox

显示一个警告框。

参数 类型 描述 默认值
content* NodeLike —
title NodeLike "警告"
onOk () => boolean | void —

返回值

类型:MessageBox

显示一个警告框。

—
⮞ MessageBox.confirm(content, ...)(content:NodeLike, title?:NodeLike, onOk?:function, onCancel?:function):MessageBox

显示一个确认框。

参数 类型 描述 默认值
content* NodeLike —
title NodeLike "确认"
onOk () => boolean | void —
onCancel () => boolean | void —

返回值

类型:MessageBox

显示一个确认框。

—
⮞ MessageBox.prompt(content, ...)(content:string, title?:NodeLike, onOk?:function, onCancel?:function):MessageBox

显示一个输入框。

参数 类型 描述 默认值
content* string —
title NodeLike "请输入"
onOk (value: string) => boolean | void —
onCancel () => boolean | void —

返回值

类型:MessageBox

显示一个输入框。

—