useFormItemWidget
useFormItemWidget 为低代码设计器中的表单元素组件提供统一的运行时上下文封装,基于 useWidget 扩展,增加其作为 表单元素 的能力。
使用方法
typescript
// 定义组件 props
const props = defineProps<WidgetRenderProps>()
// 使用 useFormItemWidget
const { 解构属性/方法 } = useFormItemWidget(useWidget(props))useFormWidget 返回值描述
| 属性/方法名 | 类型 | 说明 |
|---|---|---|
... | ... | useWidget 全部返回值 |
form | WidgetInstance | 关联表单组件实例。 |
formContext | Record<string, any> | 表单组件暴露的上下文。 |
useFormItemAttrs | () => { 'prop', 'labelControl', 'label', 'labelWidth', 'helps', 'helpsAlwaysShow'} | 返回 formItem 组件的属性。 |
useFormInputAttrs | (args?: { only?: string[]; omit?: string[] }) => { 'readonly', 'disabled', 'placeholder', ...其他属性} | 返回 表单元素 组件的属性。 |
valueModel | WritableComputedRef<any, any> | 表单元素关联的表单数据值 |
exposeContext 扩展
| 键(key) | 说明 |
|---|---|
getValue | 表单元素关联的表单数据值 |
setFormValue | 设置表单元素关联的表单数据值 |
