.. | ||
index.vue | ||
README.md |
x-n-modal 模态框组件
基于 naive-ui 的 n-modal 组件封装,提供预设配置和便捷使用方式。
特点
- 预设模态框配置,默认只能通过关闭按钮关闭
- 自动挂载到 app 根节点
- 支持所有 n-modal 原生属性和事件
使用示例
<template>
<x-n-modal v-model:show="showModal" title="标题" class="w-[1000px] h-[600px]">
<!-- 内容插槽 -->
<template #default>
模态框内容
</template>
<!-- 操作按钮插槽 -->
<template #action>
<n-button>保存</n-button>
<n-button>取消</n-button>
</template>
</x-n-modal>
</template>
<script setup>
import { ref } from 'vue'
const showModal = ref(false)
</script>
注意事项
- 自动挂载到 id="app" 的根节点
- 默认禁用 ESC 和点击遮罩关闭
- 支持通过属性覆盖默认配置