TuModal 确认弹窗

居中面板 + 遮罩,confirm / cancel / close 事件,confirmLoading / showCancel / maskClosable。

确认弹窗:居中面板 + 遮罩。完全受控:visible 由父级维护;确认 / 取消 / 遮罩关闭分别触发 confirm / cancel / close 事件。动画由 visibility + opacity 过渡驱动,隐藏态 pointer-events 隔离交互。

属性
名称类型说明
visibleboolean是否显示(受控),默认 false。
titlestring标题。
contentstring内容文本(children 存在时忽略)。
confirmTextstring确认按钮文案,默认「确认」。
cancelTextstring取消按钮文案,默认「取消」。
showCancelboolean是否显示取消按钮,默认 true。
confirmLoadingboolean确认按钮加载态(不响应点击),默认 false。
maskClosableboolean点击遮罩是否触发 close,默认 false。
childrenArray<VNode | string>内容插槽(覆盖 content 文本)。

事件:confirm(confirmLoading 时不触发)、cancelclose(maskClosable 为 true 时点击遮罩触发)。

打开弹窗
确认删除
删除后不可恢复,确定要继续吗?
取消
确认

上次操作:尚未操作 —— 弹窗完全受控:confirm / cancel / close 三个事件回传父级。

实例

ts
createComponent({
  component: TuModal,
  props: {
    visible: this.state.confirmVisible,
    title: '删除确认',
    content: '删除后不可恢复,确定继续?',
    confirmLoading: this.state.deleting,
  },
  emitters: {
    confirm: () => this.doDelete(),
    cancel: () => (this.state.confirmVisible = false),
  },
})