feat: migrate Form component

This commit is contained in:
chenjiahan
2020-08-19 17:50:34 +08:00
parent e5368ed2f9
commit b6b6e38c45
12 changed files with 31 additions and 22 deletions
+2 -2
View File
@@ -3,14 +3,14 @@
readonly
clickable
name="area"
:value="value"
:label="t('picker')"
:model-value="value"
:placeholder="t('placeholder')"
@click="showArea = true"
>
<template #extra>
<van-popup
v-model="showArea"
v-model:show="showArea"
round
position="bottom"
get-container="body"
+2 -2
View File
@@ -3,14 +3,14 @@
readonly
clickable
name="calendar"
:value="value"
:label="t('calendar')"
:model-value="value"
:placeholder="t('placeholder')"
@click="showCalendar = true"
>
<template #extra>
<van-calendar
v-model="showCalendar"
v-model:show="showCalendar"
round
get-container="body"
@confirm="onConfirm"
+2 -2
View File
@@ -3,14 +3,14 @@
readonly
clickable
name="datetimePicker"
:value="value"
:label="t('label')"
:model-value="value"
:placeholder="t('placeholder')"
@click="showPicker = true"
>
<template #extra>
<van-popup
v-model="showPicker"
v-model:show="showPicker"
round
position="bottom"
get-container="body"
+2 -2
View File
@@ -3,14 +3,14 @@
readonly
clickable
name="picker"
:value="value"
:label="t('picker')"
:model-value="value"
:placeholder="t('placeholder')"
@click="showPicker = true"
>
<template #extra>
<van-popup
v-model="showPicker"
v-model:show="showPicker"
round
position="bottom"
get-container="body"
+6 -3
View File
@@ -1,5 +1,5 @@
import { createNamespace } from '../utils';
import { sortChildren } from '../utils/vnodes';
// import { sortChildren } from '../utils/vnodes';
const [createComponent, bem] = createNamespace('form');
@@ -30,6 +30,8 @@ export default createComponent({
},
},
emits: ['submit', 'failed'],
provide() {
return {
vanForm: this,
@@ -133,7 +135,8 @@ export default createComponent({
addField(field) {
this.fields.push(field);
sortChildren(this.fields, this);
// TODO
// sortChildren(this.fields, this);
},
removeField(field) {
@@ -176,7 +179,7 @@ export default createComponent({
render() {
return (
<form class={bem()} onSubmit={this.onSubmit}>
{this.slots()}
{this.$slots.default?.()}
</form>
);
},