// script ts import DataForm, { useDataForm } from '@/components/DataForm' const { config, setItems, setOptions } = useDataForm() // 设置表单属性 setOptions({ labelWidth: 100, }) // 设置字段 setItems({ name: { component: 'NInput', defaultValue: '佚名', required: true, labelRender: () => h('span', ['姓名']), } }) // 点击提交 function submit(values: any) { console.log('验证通过',values) }"> // script ts import DataForm, { useDataForm } from '@/components/DataForm' const { config, setItems, setOptions } = useDataForm() // 设置表单属性 setOptions({ labelWidth: 100, }) // 设置字段 setItems({ name: { component: 'NInput', defaultValue: '佚名', required: true, labelRender: () => h('span', ['姓名']), } }) // 点击提交 function submit(values: any) { console.log('验证通过',values) }"> // script ts import DataForm, { useDataForm } from '@/components/DataForm' const { config, setItems, setOptions } = useDataForm() // 设置表单属性 setOptions({ labelWidth: 100, }) // 设置字段 setItems({ name: { component: 'NInput', defaultValue: '佚名', required: true, labelRender: () => h('span', ['姓名']), } }) // 点击提交 function submit(values: any) { console.log('验证通过',values) }">
// template
// <DataForm v-bind="config" @submit="submit" />
// script ts
import DataForm, { useDataForm } from '@/components/DataForm'
const { config, setItems, setOptions } = useDataForm()
// 设置表单属性
setOptions({
labelWidth: 100,
})
// 设置字段
setItems({
name: {
component: 'NInput',
defaultValue: '佚名',
required: true,
labelRender: () => h('span', ['姓名']),
}
})
// 点击提交
function submit(values: any) {
console.log('验证通过',values)
}