Skip to content

模态框组件 ​

基于 naive-ui 的modal二次封装。

INFO

无需引入,可直接使用

Usage ​

vue
<template>
  <WModal
    v-model:show="modalVisible"
    :loading="isLoading"
    title="操作提示"
    help-message="确认执行此操作?"
    width="50%"
    height="auto"
    :fullscreen="true"
    :default-button="true"
    :segmented="true"
    :before-close="beforeClose"
    @yes="onYes"
    @no="onNo"
  >
    模态框内容
  </WModal>
</template>

Props ​

名称类型默认值说明
showbooleanfalse控制模态框显示/隐藏
loadingbooleanfalse是否显示加载状态
titlestring-模态框标题
help-messagestring-标题帮助提示信息
widthstring'25%'模态框宽度(支持百分比/px)
heightstring'auto'模态框高度(支持百分比/px)
fullscreenbooleantrue是否支持全屏
default-buttonbooleantrue是否显示默认确认/取消按钮
segmentedbooleantrue是否显示分割线(soft风格)
before-closefunction-关闭前回调(返回false可阻止关闭)
ts
import type { ModalProps } from 'naive-ui'

export interface ICompUIModalProps extends /* @vue-ignore */ Omit<ModalProps, 'segmented'> {
  show?: boolean
  loading?: boolean
  title?: string
  helpMessage?: string
  width?: string
  height?: string
  fullscreen?: boolean
  defaultButton?: boolean
  segmented?: boolean
  beforeClose?: () => Promise<boolean>
}

基于 MIT 许可发布