feat: 更新 PSelect 组件,支持异步选项加载并优化 blur 事件处理
This commit is contained in:
@ -17,6 +17,19 @@ async function submit(formData: Record<string, any>, formNode: FormKitNode) {
|
||||
timer: 1500
|
||||
})
|
||||
}
|
||||
|
||||
const K_OPTIONS = [
|
||||
{ label: 'Option 1', value: 'Value 1' },
|
||||
{ label: 'Option 2', value: 'Value 2' },
|
||||
{ label: 'Option 3', value: 'Value 3' },
|
||||
];
|
||||
const promiseOptions = () => {
|
||||
return new Promise<typeof K_OPTIONS>(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(K_OPTIONS);
|
||||
}, 1000);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -71,47 +84,55 @@ async function submit(formData: Record<string, any>, formNode: FormKitNode) {
|
||||
name="PSelect"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="[
|
||||
'Option 1',
|
||||
'Option 2',
|
||||
'Option 3',
|
||||
]"
|
||||
valuee="Option 2"
|
||||
:options="K_OPTIONS"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
/>
|
||||
<FormKit
|
||||
v-if="!value?.PInputPassword"
|
||||
:type="text"
|
||||
:preserve="false"
|
||||
name="customType"
|
||||
value="this input will display if the password is empty"
|
||||
>
|
||||
<!-- <template #label>
|
||||
type="PSelect"
|
||||
name="PSelect"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="promiseOptions()"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
/>
|
||||
<div class="flex gap-4">
|
||||
<FormKit
|
||||
v-if="!value?.PInputPassword"
|
||||
:type="text"
|
||||
:preserve="false"
|
||||
name="customType"
|
||||
value="this input will display if the password is empty"
|
||||
>
|
||||
<!-- <template #label>
|
||||
<div>labelll</div>
|
||||
</template> -->
|
||||
</FormKit>
|
||||
|
||||
|
||||
<FormKit
|
||||
type="group"
|
||||
name="group"
|
||||
>
|
||||
<FormKit
|
||||
type="text"
|
||||
name="text-in-group-1"
|
||||
>
|
||||
</FormKit>
|
||||
</FormKit>
|
||||
|
||||
<FormKit
|
||||
type="group"
|
||||
name="group"
|
||||
>
|
||||
|
||||
<FormKit
|
||||
type="text"
|
||||
name="text-in-group-2"
|
||||
type="group"
|
||||
name="group"
|
||||
>
|
||||
<FormKit
|
||||
type="text"
|
||||
name="text-in-group-1"
|
||||
>
|
||||
</FormKit>
|
||||
</FormKit>
|
||||
</FormKit>
|
||||
|
||||
<FormKit
|
||||
type="group"
|
||||
name="group"
|
||||
>
|
||||
<FormKit
|
||||
type="text"
|
||||
name="text-in-group-2"
|
||||
>
|
||||
</FormKit>
|
||||
</FormKit>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
label="Button"
|
||||
|
Reference in New Issue
Block a user