From c499a92606157c0a4836e96127823f4e00bf6a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Wed, 20 Nov 2024 15:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 ++++++++++---------- formkit.addAsteriskPlugin.ts | 2 +- src/App.vue | 44 ++++++++++++++++++++++++++++++------ src/main.ts | 1 + 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4de3dc9..636c3e7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# Vue FormKit Example +# [Vue FormKit Example](https://formkit.com) -- https://github.com/mathsgod/formkit-element - ---- -- https://themes.formkit.com/editor?theme=regenesis +## Example - https://formkit.com/essentials/examples -- https://formkit.com/essentials/inputs#sections -- https://formkit.com/essentials/architecture#getting-a-components-node -- https://formkit.com/essentials/architecture#getting-a-components-node#message-store -- https://formkit.com/essentials/validation#showing-errors -- https://formkit.com/inputs/form#useformkitcontext ---- -- https://github.com/formkit/formkit/blob/master/packages/addons/src/plugins/autoHeightTextarea.ts \ No newline at end of file +## Knowledge +- [sections](https://formkit.com/inputs/text#sections) +- [sections](https://formkit.com/essentials/inputs#sections) +- [useformkitcontext](https://formkit.com/inputs/form#useformkitcontext) + +## Theme +- https://themes.formkit.com/editor?theme=regenesis + +## 3rd Party +- https://github.com/mathsgod/formkit-element \ No newline at end of file diff --git a/formkit.addAsteriskPlugin.ts b/formkit.addAsteriskPlugin.ts index 11c4fbc..73463d3 100644 --- a/formkit.addAsteriskPlugin.ts +++ b/formkit.addAsteriskPlugin.ts @@ -7,7 +7,7 @@ export function addAsteriskPlugin(node: FormKitNode) { node.on('created', () => { const legendOrLabel = legends.includes(`${node.props.type}${node.props.options ? '_multi' : ''}`) ? 'legend' : 'label'; - console.group(node.props.label || node.props.submitLabel) + console.group('[node created]', node.props.label || node.props.submitLabel) console.debug(`node :>> `, node); console.debug(`node.props.definition :>> `, node.props.definition); // if (typeof node.props.definition!.schema === 'function') { diff --git a/src/App.vue b/src/App.vue index cd1da9e..7248cea 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,15 +15,15 @@ const castNumber = (node: FormKitNode) => { onMounted(() => { console.group('onMounted') - const nameNode = getNode('nameNodeId') + const nameNode = getNode('nameNodeId') // 用 id 获取节点 Object.assign(window, { nameNode }) console.debug(`nameNode :>> `, nameNode); - const schemaGroupInput = nameNode!.root.at('schemaGroup.input') + const schemaGroupInput = nameNode?.root.at('schemaGroup.input') // 用路径获取节点 console.debug(`schemaGroupInput :>> `, schemaGroupInput); - nameNode!.on('commit', ({ payload }) => { + nameNode?.on('commit', ({ payload }) => { console.debug('[nameNode] [on commit]', `payload :>> `, payload); - schemaGroupInput!.input(`姓名:${payload}`) + schemaGroupInput?.input(`姓名:${payload}`) }) console.groupEnd() }) @@ -58,6 +58,18 @@ const SCHEMA: FormKitSchemaDefinition = [ } ]; +function onChangeName() { + const nameNode = getNode('nameNodeId') + nameNode?.input('测试') +} + +import autoAnimate from "@formkit/auto-animate" +onMounted(() => { + // setTimeout(() => { + autoAnimate(document.getElementById('attributes-group-wrapper')!); + // }); +}) +