Skip to content

Commit dc7878f

Browse files
committed
fix: demo page
1 parent 8310e49 commit dc7878f

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

playground/src/views/examples/form/custom.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const [Form] = useVbenForm({
1818
},
1919
labelClass: 'w-2/6',
2020
},
21-
fieldMappingTime: [['field4', ['areaCode', 'phone'], null]],
21+
fieldMappingTime: [['field4', ['phoneType', 'phoneNumber'], null]],
2222
// 提交函数
2323
handleSubmit: onSubmit,
2424
// 垂直布局,label和input在不同行,值为vertical
@@ -56,16 +56,19 @@ const [Form] = useVbenForm({
5656
},
5757
{
5858
component: markRaw(TwoFields),
59-
defaultValue: [undefined, '188'],
59+
defaultValue: [undefined, ''],
6060
disabledOnChangeListener: false,
6161
fieldName: 'field4',
6262
formItemClass: 'col-span-1',
6363
label: '组合字段',
6464
rules: z
6565
.array(z.string().optional())
66-
.length(2, '请输入手机号码')
66+
.length(2, '请选择类型并输入手机号码')
6767
.refine((v) => !!v[0], {
68-
message: '请选择区号',
68+
message: '请选择类型',
69+
})
70+
.refine((v) => !!v[1] && v[1] !== '', {
71+
message: '       输入手机号码',
6972
})
7073
.refine((v) => v[1]?.match(/^1[3-9]\d{9}$/), {
7174
// 使用全角空格占位,将错误提示文字挤到手机号码输入框的下面

playground/src/views/examples/form/modules/two-fields.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script lang="ts" setup>
22
import { Input, Select } from 'ant-design-vue';
33
4-
const emit = defineEmits(['blur', 'change', 'change']);
4+
const emit = defineEmits(['blur', 'change']);
55
66
const modelValue = defineModel<[string, string]>({
7-
default: ['+85', ''],
7+
default: () => [undefined, undefined],
88
});
99
1010
function onChange() {
@@ -16,19 +16,21 @@ function onChange() {
1616
<Select
1717
v-model:value="modelValue[0]"
1818
class="w-[80px]"
19-
show-search
20-
placeholder="区码"
19+
placeholder="类型"
20+
allow-clear
2121
:class="{ 'valid-success': !!modelValue[0] }"
22+
:options="[
23+
{ label: '个人', value: 'personal' },
24+
{ label: '工作', value: 'work' },
25+
{ label: '私密', value: 'private' },
26+
]"
2227
@blur="emit('blur')"
2328
@change="onChange"
24-
>
25-
<Select.Option value="+82">+82</Select.Option>
26-
<Select.Option value="+85">+85</Select.Option>
27-
<Select.Option value="+86">+86</Select.Option>
28-
</Select>
29+
/>
2930
<Input
3031
placeholder="请输入11位手机号码"
3132
class="flex-1"
33+
allow-clear
3234
:class="{ 'valid-success': modelValue[1]?.match(/^1[3-9]\d{9}$/) }"
3335
v-model:value="modelValue[1]"
3436
:maxlength="11"

0 commit comments

Comments
 (0)