<tap-dialog>
模态对话框组件。提供标题、内容、确定和取消按钮,并支持静态方法命令式调用。
Example
Loading...
<tap-button @click=${(evt) => (evt.target.nextElementSibling.open = true)}>
打开对话框
</tap-button>
<tap-dialog
.open=${true}
.maskClosable=${true}
.header=${"操作确认"}
.body=${"确定要执行此项操作吗?此操作无法撤销。"}
.okText=${"确认"}
.cancelText=${"取消"}
@close=${(evt) => (evt.target.open = false)}
@ok=${(evt) => (evt.target.open = false)}
@maskclick=${(evt) => (evt.target.open = false)}></tap-dialog>
命令式调用
import { TapDialogElement } from '@mantou/tap-ui/elements/dialog';
TapDialogElement.open({
header: '提示',
body: '操作已成功完成!',
});
TapDialogElement.confirm({
header: '警告',
body: '此操作将永久删除数据,是否继续?',
dangerDefaultOkBtn: true,
onOk: () => {
console.log('用户确认了操作');
},
});
API
Shadow DOM; Extends GemElement
Constructor TapDialogElement()
| Params |
Type |
options |
DialogOptions |
Static Methods
| Method |
Type |
open |
<T = Element>(options: DialogOptions & DialogOpenOptions<T>) => DyPromise<T, { modal: TapDialogElement; }> & { modal: TapDialogElement; } |
confirm |
(body: string | TemplateResult | Record<string, unknown>, options?: DialogOptions) => DyPromise<Element, { modal: TapDialogElement; }> & { modal: TapDialogElement; } |
Instance Properties
| Property(Attribute) |
Reactive |
Type |
open(open) |
Yes |
boolean |
customize(customize) |
Yes |
boolean |
maskClosable(mask-closable) |
Yes |
boolean |
okText(ok-text) |
Yes |
string |
cancelText(cancel-text) |
Yes |
string |
disableDefaultCancelBtn(disable-default-cancel-btn) |
Yes |
boolean |
disableDefaultOKBtn(disable-default-okbtn) |
Yes |
boolean |
dangerDefaultOkBtn(danger-default-ok-btn) |
Yes |
boolean |
header(header) |
Yes |
string |
body(body) |
Yes |
string |
close |
|
Emitter |
ok |
|
Emitter |
maskclick |
|
Emitter |
openAnimation |
Yes |
PropertyIndexedKeyframes | Keyframe[] |
closeAnimation |
Yes |
PropertyIndexedKeyframes | Keyframe[] |
headerSlot |
Yes |
string | TemplateResult |
bodySlot |
Yes |
string | TemplateResult |
footerSlot |
Yes |
string | TemplateResult |
Other
| Type |
Value |
| Event |
close, ok, maskclick |
| Slot |
header, unnamed, footer |
| Part |
dialog, divider, body |
| CSS State |
closing |