vue3中使用render函数以及组合式写法实现一个配置化生成的表单组件

表单组件代码

import {
    h, computed, ref } from 'vue'
import type {
    PropType } from 'vue'
import {
    Form, Input, Radio, FormItem, Checkbox } from '@arco-design/web-vue'

//去除定义类型中 指定的key
type RestrictKey<T, K extends keyof any> = {
   
  [P in keyof T]: P extends K ? never : T[P];
};

//FormPropsType 类型中的属性与官网form 组件的属性保持一致 但不用再声明model属性
export type FormPropsType =RestrictKey<{
   
  model?: string; 
  items: {
   
    [key: string]: {
   
        type: 'radio' | 'input' | 'checkbox' | 'slot'
        //config 类型中的属性与官网formItem 组件的属性保持一致 但不用再声明field属性
        config: RestrictKey<{
   
          [key: string]: any;
          field?: string; 
      },'field'> //去除field属性 不允许传model属性
        slotFormConfig: {
   
            modelValue: any
            [key: string]: any
        }
    }
}
  [key
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值