Giter Site home page Giter Site logo

tirelyl / qing-form Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 4.0 3.71 MB

QingForm 是一个用于 Angular 动态创建表单的库,JSON配置,支持字段间的灵活联动

Home Page: https://tirelyl.github.io/qing-form/docs

License: MIT License

JavaScript 5.53% TypeScript 72.36% HTML 15.18% CSS 6.94%

qing-form's Introduction

QingForm 📃

QingForm 是一个用于 Angular 动态创建表单的库,JSON配置,支持字段间的灵活联动 GitHub 地址:https://github.com/tirelyl/qing-form

如何使用

  1. 安装 qing-form
npm install qing-form --save
  1. 导入 QingFormModule
import { NgModule } from '@angular/core';
import { QingFormModule } from 'qing-form';

@NgModule({
  imports: [
    ...,
    QingFormModule,
  ]
})
export class ShareModule { }
  1. 在组件中使用JSON来配置表单
import { Component, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { QfFieldConfig } from 'qing-form';

@Component({
  selector: 'app',
  template: `
    <form [formGroup]="form">
      <qf-form [form]="form" [fields]="fields"></qf-form>
    </form>
  `
})
export class AppComponent {
  form = new FormGroup({});
  fields: QfFieldConfig[] = [
    {
      key: '1',
      type: 'input',
      templateOptions: {
        label: '输入框',
        placeholder: '我是提示'
      }
    }
  ];
}

API

<qf-form [form]="form" [fields]="fields"></qf-form>

qf-form

参数 说明 类型 默认值
[form] 当前表单的 FormGroup 实例 Array<TemplateRef<void>> new FormGroup({})
fields 每一个表单控件的配置信息 QfFieldConfig []

QfFieldConfig

属性 说明 类型 必填
key 表单控件的唯一key,于 FormGroup 中的 key 对应 string
type 表单控件类型 'input' | 'date' | 'radio' | 'checkbox'
templateOptions 给控件设置交互相关的信息 QfTemplateOptions -

QfTemplateOptions

属性 说明 类型 必填
label 控件标题 string -
placeholder 控件默认文字 string -
defaultValue 控件默认值 any -
options 选择类型控件选项 Array<{ label: string; value: string; checked?: boolean; }> -
valueType 控件值联动类型 'string' | 'formula' | 'custom' -
formula 联动值类型为 formula 时,需要计算的公式 string -

qing-form's People

Contributors

tirelyl avatar

Stargazers

 avatar  avatar Eve-Sama avatar  avatar Jimmy Yen avatar 云小飞 avatar  avatar Shuaitong Yang avatar ruir avatar  avatar dusdong avatar Yadong Xie avatar Wenqi Chen avatar Hsuan Lee avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.