wip(VForm): VForm component development
parent
cdb5c5f0b1
commit
d71bc5d6f5
@ -1,42 +1,86 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, unref, reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import { ElConfigProvider } from 'element-plus'
|
import { ElConfigProvider, ElIcon } from 'element-plus'
|
||||||
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
||||||
// import en from 'element-plus/lib/locale/lang/en'
|
// import en from 'element-plus/lib/locale/lang/en'
|
||||||
import { VFrom, VFormExpose } from '@/components/Form'
|
import { VFrom } from '@/components/Form'
|
||||||
const formRef = ref<ComponentRef<typeof VFrom> & VFormExpose>()
|
import Calendar from '~icons/ep/calendar'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
const form = unref(formRef.value)
|
|
||||||
console.log(form)
|
|
||||||
})
|
|
||||||
const schema = reactive<VFormSchema[]>([
|
const schema = reactive<VFormSchema[]>([
|
||||||
{
|
{
|
||||||
field: 'field1',
|
field: 'field1',
|
||||||
component: 'Divider',
|
component: 'Divider',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
text: 'input示例'
|
text: 'Input'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'field2',
|
field: 'field2',
|
||||||
label: '字段1',
|
label: 'default',
|
||||||
component: 'Input'
|
component: 'Input'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field3',
|
||||||
|
label: 'input-icon1',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
suffixIcon: Calendar,
|
||||||
|
prefixIcon: Calendar
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field4',
|
||||||
|
label: 'input-icon2',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
slots: {
|
||||||
|
suffix: true,
|
||||||
|
prefix: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field5',
|
||||||
|
label: 'input-mixed',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
slots: {
|
||||||
|
prepend: true,
|
||||||
|
append: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field6',
|
||||||
|
label: 'textarea',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
type: 'textarea',
|
||||||
|
rows: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field7',
|
||||||
|
component: 'Divider',
|
||||||
|
componentProps: {
|
||||||
|
text: 'Autocomplete'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ElConfigProvider :locale="zhCn">
|
<ElConfigProvider :locale="zhCn">
|
||||||
<!-- <VFrom ref="formRef" is-custom>
|
<VFrom :schema="schema">
|
||||||
<template #default> hahahah </template>
|
<template #field4-prefix>
|
||||||
</VFrom> -->
|
<ElIcon class="el-input__icon"><Calendar /></ElIcon>
|
||||||
<VFrom :schema="schema" />
|
</template>
|
||||||
<!-- <VFrom :is-col="false" :schema="schema" /> -->
|
<template #field4-suffix>
|
||||||
<!-- <Component :is="VFrom" /> -->
|
<ElIcon class="el-input__icon"><Calendar /></ElIcon>
|
||||||
<!-- <RouterView class="app" /> -->
|
</template>
|
||||||
<div>{{ t('common.inputText') }}</div>
|
|
||||||
|
<template #field5-prepend> Http:// </template>
|
||||||
|
<template #field5-append> .com </template>
|
||||||
|
</VFrom>
|
||||||
</ElConfigProvider>
|
</ElConfigProvider>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
Reference in New Issue