feat: 更新 PSelect 组件,支持异步选项加载并优化配置,调整样式以改善用户体验
All checks were successful
/ test (push) Successful in 21s
/ surge (push) Successful in 57s

This commit is contained in:
严浩
2024-12-06 15:05:16 +08:00
parent 7b7828d384
commit a6ccc16adb
5 changed files with 58 additions and 27 deletions

View File

@ -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"