3.0.8 • Published 8 months ago

form-render4-vue3-pro v3.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

form-render4-vue3-pro 是基于 vue3 的表单生成组件,组件包含了日常使用的表单组件,意在解决项目日常开发中表单代码重复书写的问题,提高开发效率。

项目目前支持UI库: 1. element-plus 2. arco-design

在线演示

💎 更新日志

🌈 如何使用

安装

npm install form-render4-vue3-pro --save
// main.js
import { createApp } from 'vue'
// import FormRender4Vue3 from 'form-render4-vue3-pro/arco-design'
import FormRender4Vue3 from 'form-render4-vue3-pro/element-plus'
import App from './App.vue'

const app = createApp(App)
app.use(FormRender4Vue3,{ warning:false }) // 安装组件时可选择警告信息打印与否 
app.mount('#app')
<template>
  <!-- 你的组件 -->
  <form-render4-vue3-pro
    :schema="schema"
    v-model="formData"
    :option-data="optionData"
  />
</template>

<script setup>
import { reactive } from 'vue'

const formData = reactive({})
const optionData = reactive({
  address: {
    list: [
      {
        label: '北京',
        value: 'beijing',
      },
      {
        label: '上海',
        value: 'shanghai',
      },
      {
        label: '深圳',
        value: 'shenzhen',
      },
      {
        label: '成都',
        value: 'chengdu',
      },
    ],
    key: 'value',
  },
})
const schema = reactive({
  props: {
    layout: 'horizontal',
    labelAlign: 'left',
  },
  fields: [
    {
      type: 'input',
      title: '姓名',
      field: 'name',
      value: '',
      props: {
        placeholder: '输入姓名',
      },
    },
    {
      type: 'select',
      title: '地址',
      field: 'address',
      value: '',
      props: {
        placeholder: '选择地址',
      },
    },
  ],
})
</script>

API

Props

参数名类型描述是否必须
modelValue(v-model)Object表单数据对象Yes
schemaObject生成表单的 JSON 对象Yes
optionDataObjectselect、checkbox、radio、tree-select、cascader、transfer等组件选项的数据源No

Methods

方法名描述参数返回值
validate校验表单全部数据-Promise
clearValidate清除校验表单校验数据--
reset重置表单字段-/string[]void

Slots

插槽名描述参数
footer页脚--

Schema 字段描述

字段名称类型Description是否必须
fieldsArray生成表单项的数组Yes
rulesObject使用方式参考 arco-design from 表单 rulesNo
props-使用方式参考 arco-design from 表单原生属性No
columnNumber生成表单项的列数Yes
gutterNumber表单项之间的间隔No

fields 字段描述

字段名称类型Description是否必须
datasourceDataSource远程加载数据配置Yes
typeString指定生成对应 arco-design 的组件,对应关系见下表 typeYes
gutterNumber用与表单项之间的间隔 ,该项不设置会自动取全局的 gutterNo
titleString表单项的名称Yes
fieldString表单项绑定的字段Yes
valueany该表表单项的值No
propsObject生成最终组件的 props 项,对应 arco-design 组件的 propsNo
spanNumber该表单项独占的栅格数(默认为 24)No
showBoolean控制表单项显示与否,默认为:trueNo
configObjecta-form-item组件配置对象,字段参考a-form-item组件属性No
childrenArray嵌套表单项No
watcherArray字段联动动作No

当前支持的组件

type对应的 arco-design 组件名
form-item表单项,复杂表单布局可能会使用到
inputa-input
input-numbera-input-number
checkboxa-checkbox
radioa-radio
switcha-switch
slidera-slider
textareaa-textarea
ratea-rate
uploada-upload
time-pickera-time-picker
verification-codea-verification-code
tree-selecta-tree-select
date-range-pickera-date-range-picker
date-pickera-date-picker
cascadera-cascader
transfera-transfer
dividera-divider
alerta-alert
colora-color
3.0.8

8 months ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.2.0

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.8

2 years ago

1.2.7

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0-alpha

2 years ago

1.3.0-beta

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago