Skip to content

Modal 弹出窗口

Modal 组件用来已弹出模态窗口的形式展示页面内容。

基本用法

动态弹出

自定义按钮-普通调用

自定义按钮-函数式调用

窗口尺寸

最大化

iframe

自定义模板

是否模态

类型

typescript
export interface ModalButton {
    class: string;
    focusedByDefault?: boolean;
    disable?: boolean;
    iconClass?: string;
    handle: ($event: MouseEvent) => void;
    text: string;
}

属性

属性名类型默认值说明
allowClickMaskToClosebooleantrue允许点击蒙层关闭对话框
beforeClosefunction() => true关闭前事件
classstring''自定义样式,类名以空格隔开
maskClassstring''自定义蒙层样式,类名以空格隔开
maskbooleanfalse是否模态
titlestring--窗口标题
widthnumber500窗口宽度
heightnumber320窗口高度
footerHeightnumber60底部区域高度,如果设置为0,则不显示底部区域
buttonsModalButton--底部按钮
modelValuebooleanfalse双向绑定属性是否显示窗口
showHeaderbooleantrue展示头部
showButtonsbooleantrue展示默认按钮
fitContentbooleantrue自适应尺寸
showHeaderbooleantrue展示头部
showHeaderbooleantrue展示头部
showCloseButtonbooleantrue展示右上角关闭弹窗按钮
showMaxButtonbooleantrue展示右上角最大化按钮
resizeablebooleantrue
draggablebooleantrue可拖拽窗口
dragHandlestring-拖拽抓手,赋值css选择器
acceptCallbackfunction-命令式调用属性,底部默认确定按钮回调事件
rejectCallbackfunction-命令式调用属性,底部默认取消按钮回调事件
closedCallbackfunction-命令式调用属性,默认关闭按钮回调事件
renderfunction-命令式调用属性,默认插槽,返回VNode

ModalButton

属性名类型默认值说明
textstring--按钮名称
classstring''自定义样式
disablebooleanfalse禁用
iconClassstring--图标class
handleFunction($event: MouseEvent, contetx: any)-按钮事件

命令式调用

按照以下方式调用

import { inject } from 'vue';
import { F_MODAL_SERVICE_TOKEN } from '@farris/ui-vue';
const modalService = inject(F_MODAL_SERVICE_TOKEN) as any;
const modalInstance = modalService.open({
    ...
});
<!-- 销毁 -->
modalInstance.destroy();

插槽

TIP

暂无内容