feat: 更新 formkit 配置,优化插件结构并修改按钮点击事件逻辑
This commit is contained in:
@ -3,7 +3,7 @@ import { PInputPassword } from '@/__fk-inputs__/inputs/input-password';
|
|||||||
import { PInputText } from '@/__fk-inputs__/inputs/input-text';
|
import { PInputText } from '@/__fk-inputs__/inputs/input-text';
|
||||||
import { createAutoAnimatePlugin, createAutoHeightTextareaPlugin } from '@formkit/addons';
|
import { createAutoAnimatePlugin, createAutoHeightTextareaPlugin } from '@formkit/addons';
|
||||||
import { autoAnimatePlugin } from '@formkit/auto-animate/vue';
|
import { autoAnimatePlugin } from '@formkit/auto-animate/vue';
|
||||||
import type { FormKitOptions } from '@formkit/core';
|
import type { FormKitOptions, FormKitPlugin } from '@formkit/core';
|
||||||
import { register as decodeErrors } from '@formkit/dev';
|
import { register as decodeErrors } from '@formkit/dev';
|
||||||
import { createI18nPlugin, zh } from '@formkit/i18n';
|
import { createI18nPlugin, zh } from '@formkit/i18n';
|
||||||
import { createLibraryPlugin, group, submit, text } from '@formkit/inputs';
|
import { createLibraryPlugin, group, submit, text } from '@formkit/inputs';
|
||||||
@ -14,10 +14,7 @@ import type { App } from 'vue';
|
|||||||
import { addAsteriskPlugin } from './formkit.config.plugin.addAsteriskPlugin';
|
import { addAsteriskPlugin } from './formkit.config.plugin.addAsteriskPlugin';
|
||||||
import { debugPlugin } from './formkit.config.plugin.debug';
|
import { debugPlugin } from './formkit.config.plugin.debug';
|
||||||
|
|
||||||
// const apiKey = 'fk-6cdd5192223'
|
const plugins: FormKitPlugin[] = [
|
||||||
const config: FormKitOptions = {
|
|
||||||
plugins: [
|
|
||||||
...[
|
|
||||||
// createProPlugin(apiKey, { toggle }),
|
// createProPlugin(apiKey, { toggle }),
|
||||||
// createLibraryPlugin(fkLibrary),
|
// createLibraryPlugin(fkLibrary),
|
||||||
createLibraryPlugin({
|
createLibraryPlugin({
|
||||||
@ -34,10 +31,10 @@ const config: FormKitOptions = {
|
|||||||
// 'headlessuiSwitch': createInput(HeadlessuiToggle),
|
// 'headlessuiSwitch': createInput(HeadlessuiToggle),
|
||||||
// }
|
// }
|
||||||
// ),
|
// ),
|
||||||
],
|
|
||||||
// createThemePlugin(
|
// createThemePlugin(
|
||||||
// theme: undefined /* icons: genesisIcons, iconLoaderUrl, iconLoader */,
|
// theme: undefined /* icons: genesisIcons, iconLoaderUrl, iconLoader */,
|
||||||
// ),
|
// ),
|
||||||
|
// #############################
|
||||||
bindings,
|
bindings,
|
||||||
createI18nPlugin({ zh }),
|
createI18nPlugin({ zh }),
|
||||||
createValidationPlugin(defaultRules),
|
createValidationPlugin(defaultRules),
|
||||||
@ -59,8 +56,14 @@ const config: FormKitOptions = {
|
|||||||
repeater: ['items'],
|
repeater: ['items'],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
debugPlugin,
|
];
|
||||||
],
|
if (import.meta.env.VITE_DEBUG_FORMKIT === 'true') {
|
||||||
|
plugins.push(debugPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const apiKey = 'fk-6cdd5192223'
|
||||||
|
const config: FormKitOptions = {
|
||||||
|
plugins,
|
||||||
config: {
|
config: {
|
||||||
// rootClasses: false,
|
// rootClasses: false,
|
||||||
// rootClasses,
|
// rootClasses,
|
||||||
|
@ -105,7 +105,7 @@ async function submit(formData: Record<string, any>, formNode: FormKitNode) {
|
|||||||
label="Button"
|
label="Button"
|
||||||
@click="() => {
|
@click="() => {
|
||||||
value!.button = value!.button || {};
|
value!.button = value!.button || {};
|
||||||
(value!.button as any).clicked = 'clicked';
|
(value!.button as any).clicked = 'clicked-这个值在@submit回调的formData里不会出现';
|
||||||
(value!.group as any)['text-in-group-1'] = 'changed-by-button';
|
(value!.group as any)['text-in-group-1'] = 'changed-by-button';
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user