{ "slug": "formmodal", "mode": "single", "examples": [ { "id": "formmodal-ex-1", "title": "基础用法", "titleSrc": "", "desc": "", "html": "
\n

FormModal 表单弹窗

\n

弹窗内嵌表单,确认提交前进行校验,校验失败阻止关闭。

\n
\n \n

\n
\n
\n
\n
\n
\n 新建用户\n \n
\n
\n
\n \n \n
姓名不能为空
\n
\n
\n \n \n
邮箱格式不正确
\n
\n
\n \n \n
\n
\n
\n \n \n
\n
\n
", "preview": { "show": [ [ 0 ], [ 1 ] ], "hide": [], "mode": "single" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "

FormModal 表单弹窗

\n

弹窗内嵌表单,确认提交前进行校验,校验失败阻止关闭。

\n\n

\n
\n
\n
\n 新建用户\n \n
\n
\n
\n \n \n
姓名不能为空
\n
\n
\n \n \n
邮箱格式不正确
\n
\n
\n \n \n
\n
\n
\n \n \n
\n
\n
", "jsx": "import { useState } from 'react';\nimport { KoleFormModal } from 'kole-ui/react';\n\nconst fields = [\n { key: 'name', label: '姓名', required: true, placeholder: '请输入姓名' },\n { key: 'email', label: '邮箱', required: true, placeholder: 'name@example.com' },\n { key: 'role', label: '角色', placeholder: '如:管理员' },\n];\n\nexport default function Demo() {\n const [visible, setVisible] = useState(false);\n\n return (\n <>\n \n { console.log(form); setVisible(false); }}\n onCancel={() => setVisible(false)}\n />\n \n );\n}", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { useState } from 'react';\nimport { KoleFormModal } from 'kole-ui/react';\n\nconst fields = [\n { key: 'name', label: '姓名', required: true, placeholder: '请输入姓名' },\n { key: 'email', label: '邮箱', required: true, placeholder: 'name@example.com' },\n { key: 'role', label: '角色', placeholder: '如:管理员' },\n];\n\nexport default function Demo(): JSX.Element {\n const [visible, setVisible] = useState(false);\n\n return (\n <>\n \n { console.log(form); setVisible(false); }}\n onCancel={() => setVisible(false)}\n />\n \n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": [ "依据 frameworks/FormModal.html:20-44 的弹窗结构(标题「新建用户」、姓名/邮箱必填并带 placeholder、角色可空、错误文案「姓名不能为空」「邮箱格式不正确」)", "visible / title / fields / value 形参见 FormModal.jsx 与 FormModal.vue3.vue defineProps(DEFAULT_FIELDS 与演示页三个字段同值)" ] } ], "curated": true }