4.0.6 • Published 6 months ago

antdv-pro-modal v4.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Ant Design Vue Pro Modal

Ant Design Vue Pro 模态对话框,可拖拽、可调整大小。

Vue Support NPM version NPM downloads License MIT

安装 Install

npm i antdv-pro-modal

简单使用 Simple Usage

首先,您应该将所需的 antdv-pro-modal 添加到库中。

// main.[js|ts]
import { createApp } from "vue";
import App from "./App.vue";

// 全局导入 "ant-design-vue
import Antd from "ant-design-vue";
import "ant-design-vue/dist/reset.css";

// 导入 antdv-pro-modal 样式文件
import 'antdv-pro-modal/dist/style.css';

const app = createApp(App);

app.use(Antd).mount("#app");

之后,您可以在Vue组件中使用模态框,如下所示:

<template>
  <a-card>
    <a-space>
      <a-button type="primary" @click="showModal"> 点击确定异步关闭 </a-button>
      <a-button type="primary" @click="handleModal">
        useModal组件方式
      </a-button>
    </a-space>
  </a-card>

  <ProModal
    v-model:visible="visible"
    title="Title"
    :mask-closable="false"
    :fullscreen="true"
    :drag="true"
    :borderDraw="true"
  >
    <div>
      ① 窗口可以拖动;<br />
      ② 窗口可以全屏、关闭;<br />
      ③ 窗口可以通过八个方向拉伸改变大小;<br />
      ④ 限制窗口最小宽度/高度。
    </div>
  </ProModal>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { ProModal, useModal } from "antdv-pro-modal";

const visible = ref<boolean>(false);

const showModal = () => {
  visible.value = !visible.value;
};

const modal = useModal();
const handleModal = () => {
  modal.open({
    drag: true,
    borderDraw: true,
    title: "Example Modal",
    content: "This is an example modal content",
    onOk: (e) => {
      console.log("Confirmed", e);
    },
    onCancel: (e) => {
      console.log("Cancelled", e);
    },
  });
};
</script>

库功能支持 API

组件模态框 ProModal

参数说明类型默认值
...Modal属性Modal 对话框-
maskClosable点击蒙层是否允许关闭booleanfalse
title标题VNode| slot-
closeIcon自定义关闭图标VNode| slot-
okText确认按钮文字string| slot确定
cancelText取消按钮文字string| slot取消
footer底部内容VNode| slot| null| false确定取消按钮
width宽度,单位pxnumber520
minWidth最小宽度,仅borderDraw开启有效number364
minHeight最小高度,仅borderDraw开启有效number256
borderDraw边界拉伸booleanfalse
drag按住标题拖动booleanfalse
centerY打开始终水平居中,偏离顶部 top:100px位置booleanfalse
fullscreen是否显示右上角的全屏按钮booleanfalse
forceFullscreen强制全屏显示booleanfalse
@fullscreen全屏按钮点击触发事件function(e)-

Hooks模态框 useModal

在页面内 const { open, close } = useModal(); 实例化后调用函数

  • close() 关闭函数
  • open(props) 打开函数,参数支持如下:
参数说明类型默认值
...ProModal属性ProModal 对话框-
width宽度,单位pxnumber416
minWidth最小宽度,仅borderDraw开启有效number416
minHeight最小高度,仅borderDraw开启有效number156
icon图标,渲染到标题左侧VNode | ()=>VNode \ -
content内容信息,渲染到默认插槽VNode | ()=>VNode | string-

基本使用示例 Basic Usage

项目目录下 演示测试 or 项目引用示例

当前版本,还在持续更新 v4

持续维护 Continuous Maintenance

# 安装所需依赖
npm install

# 打包生成dist目录含d.ts文件
npm run build
4.0.6

6 months ago

3.1.0

1 year ago

4.0.5

1 year ago

4.0.4

1 year ago

3.0.9

1 year ago

4.0.3

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

4.0.2

1 year ago

3.0.6

1 year ago