Convert Figma logo to code with AI

JakHuang logoform-generator

:sparkles:Element UI表单设计及代码生成器

9,026
2,169
9,026
136

Top Related Projects

A powerful form designer for Vue.

f-render | 基于 ElementUI 的表单设计器

:fire::fire::fire: 强大的低代码动态表单组件,通过JSON数据驱动表单渲染,适配移动端,支持可视化设计。提高开发者对表单的开发效率。目前在政务系统、OA系统、ERP系统、电商系统、流程管理等系统中已稳定应用。

A visual form designer/generator base on Vue.js, make form development simple and efficient.(基于Vue的可视化表单设计器,让表单开发简单而高效。)

✅ Painless Vue forms

Quick Overview

Form-generator is a drag-and-drop form builder for Vue.js applications. It allows developers to create complex forms with a user-friendly interface, generating both the form's visual layout and the corresponding Vue code. This tool aims to simplify the process of form creation and management in Vue projects.

Pros

  • Intuitive drag-and-drop interface for rapid form development
  • Generates clean, reusable Vue code
  • Supports a wide range of form elements and custom components
  • Includes form validation and data binding features

Cons

  • Limited to Vue.js framework, not suitable for other JavaScript frameworks
  • May require additional customization for complex, unique form requirements
  • Learning curve for understanding all available options and configurations
  • Documentation is primarily in Chinese, which may be a barrier for non-Chinese speakers

Code Examples

  1. Basic form element creation:
<template>
  <form-generator :schema="schema" v-model="formData" />
</template>

<script>
export default {
  data() {
    return {
      schema: [
        { type: 'input', field: 'name', title: 'Name' },
        { type: 'select', field: 'country', title: 'Country', options: ['USA', 'Canada', 'UK'] }
      ],
      formData: {}
    }
  }
}
</script>
  1. Adding form validation:
<template>
  <form-generator :schema="schema" v-model="formData" :rules="rules" />
</template>

<script>
export default {
  data() {
    return {
      schema: [
        { type: 'input', field: 'email', title: 'Email' }
      ],
      formData: {},
      rules: {
        email: [
          { required: true, message: 'Email is required' },
          { type: 'email', message: 'Invalid email format' }
        ]
      }
    }
  }
}
</script>
  1. Custom component integration:
<template>
  <form-generator :schema="schema" v-model="formData">
    <template #custom-component="{ field }">
      <my-custom-component v-model="formData[field]" />
    </template>
  </form-generator>
</template>

<script>
import MyCustomComponent from './MyCustomComponent.vue'

export default {
  components: { MyCustomComponent },
  data() {
    return {
      schema: [
        { type: 'custom-component', field: 'customField', title: 'Custom Input' }
      ],
      formData: {}
    }
  }
}
</script>

Getting Started

  1. Install the package:

    npm install @form-generator/vue
    
  2. Import and use in your Vue component:

    <template>
      <form-generator :schema="schema" v-model="formData" />
    </template>
    
    <script>
    import FormGenerator from '@form-generator/vue'
    
    export default {
      components: { FormGenerator },
      data() {
        return {
          schema: [
            { type: 'input', field: 'username', title: 'Username' },
            { type: 'password', field: 'password', title: 'Password' }
          ],
          formData: {}
        }
      }
    }
    </script>
    
  3. Customize the form schema and add validation rules as needed.

Competitor Comparisons

A powerful form designer for Vue.

Pros of variant-form

  • More extensive customization options for form layouts and styles
  • Better support for complex, nested form structures
  • Includes a visual form designer for easier form creation

Cons of variant-form

  • Steeper learning curve due to more advanced features
  • Less active community and fewer contributors
  • Documentation is not as comprehensive as form-generator

Code Comparison

form-generator:

<el-form-item label="Input" prop="input">
  <el-input v-model="formData.input"></el-input>
</el-form-item>

variant-form:

<vf-field-item :field="field" :designer="designer" :parent-widget="widget">
  <vf-input-widget :field="field" :designer="designer" :parent-widget="widget" />
</vf-field-item>

Both projects aim to simplify form creation in Vue.js applications, but they differ in their approach and feature set. form-generator focuses on simplicity and ease of use, making it ideal for quick form prototyping and simpler use cases. variant-form, on the other hand, offers more advanced features and customization options, making it suitable for complex form scenarios but potentially more challenging for beginners.

f-render | 基于 ElementUI 的表单设计器

Pros of f-render

  • More lightweight and focused on form rendering
  • Simpler API and easier to integrate into existing projects
  • Better support for custom components and layouts

Cons of f-render

  • Less comprehensive documentation compared to form-generator
  • Fewer built-in form components and validation rules
  • Smaller community and fewer third-party extensions

Code Comparison

f-render:

<template>
  <f-render :schema="schema" v-model="formData" />
</template>

<script>
export default {
  data() {
    return {
      schema: { /* form schema */ },
      formData: {}
    }
  }
}
</script>

form-generator:

<template>
  <fm-generate-form
    :data="formData"
    :remote="remoteFuncs"
    :value="formValues"
    ref="generateForm"
  />
</template>

<script>
export default {
  data() {
    return {
      formData: { /* form schema */ },
      remoteFuncs: { /* remote functions */ },
      formValues: {}
    }
  }
}
</script>

Both projects aim to simplify form creation in Vue.js applications, but they differ in their approach and feature set. f-render focuses on simplicity and flexibility, while form-generator offers a more comprehensive solution with additional built-in components and features. The choice between the two depends on the specific requirements of your project and the level of customization needed.

:fire::fire::fire: 强大的低代码动态表单组件,通过JSON数据驱动表单渲染,适配移动端,支持可视化设计。提高开发者对表单的开发效率。目前在政务系统、OA系统、ERP系统、电商系统、流程管理等系统中已稳定应用。

Pros of form-create

  • More comprehensive documentation and examples
  • Supports multiple UI frameworks (Element UI, iView, Ant Design Vue)
  • Offers a wider range of form components and customization options

Cons of form-create

  • Steeper learning curve due to more complex API
  • Larger bundle size, which may impact performance for simpler forms
  • Less focus on visual drag-and-drop form building

Code Comparison

form-create:

$formCreate([
    {type: 'input', field: 'name', title: 'Name'},
    {type: 'select', field: 'gender', title: 'Gender', options: [
        {value: 'male', label: 'Male'},
        {value: 'female', label: 'Female'}
    ]}
])

form-generator:

[
    {type: 'el-input', label: 'Name', prop: 'name'},
    {type: 'el-select', label: 'Gender', prop: 'gender', options: [
        {value: 'male', label: 'Male'},
        {value: 'female', label: 'Female'}
    ]}
]

Both libraries aim to simplify form creation in Vue.js applications, but they have different approaches. form-create offers more flexibility and supports multiple UI frameworks, while form-generator focuses on Element UI and provides a more straightforward API. The choice between the two depends on the specific project requirements and the developer's familiarity with the respective libraries.

A visual form designer/generator base on Vue.js, make form development simple and efficient.(基于Vue的可视化表单设计器,让表单开发简单而高效。)

Pros of vue-form-making

  • More comprehensive documentation and examples
  • Supports a wider range of form components out-of-the-box
  • Includes a visual form designer for easier form creation

Cons of vue-form-making

  • Less frequent updates and maintenance
  • Smaller community and fewer contributors
  • More complex setup and configuration process

Code Comparison

form-generator:

import { createGenerator } from '@form-generator/core'

const generator = createGenerator({
  // Configuration options
})

vue-form-making:

import FormMaking from 'form-making'
import 'form-making/dist/FormMaking.css'

Vue.use(FormMaking)

Both projects aim to simplify form creation in Vue applications, but they differ in their approach and feature set. form-generator focuses on a more lightweight and flexible solution, while vue-form-making offers a more comprehensive toolkit with visual design capabilities.

form-generator provides a simpler API and is easier to integrate into existing projects. It also receives more frequent updates and has a larger community of contributors. However, it may require more manual configuration for complex forms.

vue-form-making, on the other hand, offers a visual form designer and a wider range of pre-built components, making it easier for non-technical users to create forms. However, it has a steeper learning curve and may be overkill for simpler projects.

Ultimately, the choice between these two libraries depends on the specific needs of your project and your team's expertise.

✅ Painless Vue forms

Pros of vee-validate

  • Lightweight and focused on form validation
  • Extensive documentation and community support
  • Seamless integration with Vue.js ecosystem

Cons of vee-validate

  • Limited to form validation, not a complete form generation solution
  • Requires more manual setup for complex form scenarios
  • Less visual customization options out-of-the-box

Code Comparison

vee-validate:

import { Form, Field, ErrorMessage } from 'vee-validate';

<Form @submit="onSubmit">
  <Field name="email" as="input" type="email" />
  <ErrorMessage name="email" />
  <button type="submit">Submit</button>
</Form>

form-generator:

import FormGenerator from '@form-generator/core';

<FormGenerator
  :schema="formSchema"
  :model="formData"
  @submit="handleSubmit"
/>

Summary

vee-validate is a lightweight form validation library for Vue.js, offering extensive documentation and seamless integration with the Vue ecosystem. It focuses solely on validation, requiring more manual setup for complex forms. form-generator, on the other hand, provides a more comprehensive form generation solution with visual customization options but may be overkill for simple validation tasks. The choice between the two depends on the specific project requirements and complexity of the forms needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

image

简介

Element UI表单设计及代码生成器,可将生成的代码直接运行在基于Element的vue项目中;也可导出JSON表单,使用配套的解析器将JSON解析成真实的表单。

文档

JSON解析器

将保存在数据库中的JSON表单,解析成真实的表单
查看在线示例

// 安装
npm i form-gen-parser

更多信息

vscode插件

帮助使用element UI的开发者完成基本的表单代码搭建任务,减少重复的劳动。
vscode-plugin分支配套插件为:form-generator-plugin;
使用插件可右键打开设计器,直接将代码保存到工程中。
安装插件请在vscode中搜索:

jakHuang
或
Form Generator Plugin

运行

  • 确保已经安装node.js 10+
  • 首次下载项目后,安装项目依赖:
yarn

或

npm install
  • 本地开发
npm run dev
  • 构建
npm run build

交流

  • QQ群 976154366【已满】 1137173566【已满】 514953560【3群】

友情链接

PR鸣谢

捐赠

如果您觉得本项目对您有帮助,可以请作者喝一杯咖啡, 让开源走的更远,感谢支持。

也请您在捐赠后,加下qq群:976154366,私聊群主留个赞助链接。

开源协议

MIT