-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[comp:modal] add modal component #346
Comments
Translation of this issue:[COMP: MODAL] Add MODAL COMPONENT
What proBLEES THIS Feature SOLVE?What does the proposed API Look Like?APIix-modalMODALPROPS
export interface ModalButton extends ButtonProps {
// 是否显示该按钮, 默认为 true
show?: boolean
// 按钮点击回调
onClick?: (evt: Event) => void
} ix-modal-providerIf you want to create a dialog via <!-- App.vue -->
<ix-modal-provider>
<MyComponent />
</ix-modal-provider>
<!-- MyComponent.vue -->
<template>
<ix-button @click="openModal">
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { useModal } from '@idux/components/modal'
export default defineComponent({
setup() {
const modal = useModal()
const openModal = ()=> modal.open(options)
return { openModal }
},
})
</script> usemodelconst { open, info, success, error, warning, confirm, destroy, destroyAll } = useModel()
export interface ModalOptions extends ModelProps {
// 对话框内容
content: string | VNode | () => VNode
}
export interface ModalBindings {
// 对话框的唯一标识
id: string
// 关闭对话框
close: () => void
// 销毁对话框
destroy: () => void
// 手动触发取消按钮
cancel: () => void
// 手动触发确定按钮
confirm: () => void
// 更新配置信息
update: (options: Partial<ModalOptions>) => void
}
export interface ModalInstance = InstanceType<DefineComponent<ModalProps>> Calling
|
支持两种使用方式
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this feature solve?
What does the proposed API look like?
API
ix-modal
ModalProps
v-model:visible
boolean
false
cancelButton
ButtonProps
cancelText
string
取消
centered
boolean
true
closable
boolean
true
closeIcon
string | #closeIcon
close
closeOnEsc
esc
关闭boolean
true
confirmButton
ButtonProps
confirmText
string
确定
containerClass
string
destroyOnHide
boolean
false
footer
ModalButtonProps[] | VNode | #footer
null
表示不显示header
sting | HeaderProps | #header
icon
string | VNode | #icon
type
不为default
时有效mask
boolean
true
maskClosable
boolean
true
title
sting | VNode | #title
type
不为default
时有效type
'default' | 'confirm' | 'info' | 'success' | 'warning' | 'error'
default
width
sting | number
640
zIndex
z-index
number
1000
onAfterOpen
() => void
onAfterClose
() => void
onClose
(evt: Event) => void | boolean | Promise<void | boolean>
false
的时候,将阻止关闭onCancel
(evt: Event) => void | boolean | Promise<void | boolean>
false
的时候,将阻止关闭onConfirm
(evt: Event) => void | boolean | Promise<void | boolean>
false
的时候,将阻止关闭ModalBindings
ix-modal-provider
如果你想通过
useModel
来创建对话框,则你需要把组件包裹在ix-modal-provider
内部,因为这样才不会丢失应用的上下文信息。useModel
可以使用
useModal
来快速创建和管理对话框,需要注意以下几点。visible
默认为true
destroyOnHide
默认为true
, 并且销毁的不仅是子元素,而是组件实例, 会触发onDestroy
回调modalToken
可以在子组件中注入该
token
来获取对话框的属性和方法,以便于控制对话框的行为。The text was updated successfully, but these errors were encountered: