feat: 更新 PSelect 组件,支持异步选项加载并优化配置,调整样式以改善用户体验
This commit is contained in:
@ -23,13 +23,13 @@ const K_OPTIONS = [
|
||||
{ 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);
|
||||
});
|
||||
};
|
||||
const promiseOptions = new Promise<typeof K_OPTIONS>(resolve => {
|
||||
setTimeout(() => resolve(K_OPTIONS), 1000);
|
||||
});
|
||||
/* const funcOptions = async () => {
|
||||
await new Promise(r => setTimeout(r, 1000))
|
||||
return K_OPTIONS;
|
||||
} */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -81,7 +81,7 @@ const promiseOptions = () => {
|
||||
/>
|
||||
<FormKit
|
||||
type="PSelect"
|
||||
name="PSelect"
|
||||
name="PSelect_1"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="K_OPTIONS"
|
||||
@ -90,14 +90,22 @@ const promiseOptions = () => {
|
||||
/>
|
||||
<FormKit
|
||||
type="PSelect"
|
||||
name="PSelect"
|
||||
name="PSelect_2"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="promiseOptions()"
|
||||
:options="promiseOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
/>
|
||||
<div class="flex gap-4">
|
||||
<FormKit
|
||||
type="dropdown"
|
||||
name="dropdown"
|
||||
label="选择框"
|
||||
validation="required"
|
||||
:options="() => { return K_OPTIONS }"
|
||||
/>
|
||||
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<FormKit
|
||||
v-if="!value?.PInputPassword"
|
||||
:type="text"
|
||||
|
Reference in New Issue
Block a user