Rule

rule-info

Description

The configuration item name of the JSON rule is the same as the configuration method name of the component generator, and the configuration parameters are the same

For example to generate an input component:

JSON rules

  1. {
  2. field: 'test',
  3. type: 'input',
  4. title: 'textTitle'
  5. props:{
  6. disable: true
  7. },
  8. on:{
  9. change:function(){
  10. }
  11. }
  12. }

Generate the same rules with Maker

  1. maker.create('input','test','textTitle').props({
  2. disable: true
  3. }).on({
  4. change:function(){
  5. }
  6. })

Basic Rules

type

  • Type: String
  • Description: Set the name of the generated component

field

  • Type: String
  • Description: Set the field name of the form component, Custom component can not be configured

title

  • Type: String
  • Description: The name of the component, you can not set

name

  • Type: String
  • Description: Field name of the custom component

value

  • Type: any
  • Description: Field values ​​for form components, custom components can be set without

native

  • Type: Bool
  • Description: Whether to generate components as they are, not nested in FormItem

hidden

  • Type: Bool
  • Description: Set whether the component is displayed

info

  • Type: String
  • Description: Set the prompt information for the component
  • Global Configuration Description: iview | element-ui

className

  • Type: String
  • Description: Set the class of the component

Extension rules

validate

  • Type: Array
  • Description: Set validation rules for form components

options

  • Type: Array
  • Description: Set radio, select, checkbox and other components option options

inject

  • Type: any
  • Description: Set event injection is custom data

col

  • Type: Object
  • Description: Set layout rules for components

control

  • Type: Object
  • Description: Controlling other component displays

description

children

  • Type: Array<rule|string|maker>
  • Description: Set the slot of the parent component. The default is default. It can be used with the slot configuration item.
  • Example 1

    1. formCreate.maker.create('button').children([
    2. 'Button content'
    3. ]);
  • Example 2

    1. maker.input('text','text','text').children([
    2. Maker.create('span').children(['append']).slot('append')
    3. ])
  • Example 3

    1. formCreate.maker.create('i-row').children([
    2. formCreate.maker.create('i-col').props('span',12).children([
    3. formCreate.maker.template('<span>custom component</span>', new Vue)
    4. ]),
    5. ]);

emit

  • Type: Array
  • Description: The event name triggered by the emit mode is configured in component mode, which can be combined with the emitPrefix parameter.

Example:

  1. // The following three ways have the same effect
  2. rules = [{//emit mode triggers change event
  3. field: 'goods_name',
  4. //...
  5. emit:['change']
  6. },{// custom emit event prefix, default is field field
  7. field: 'goods_info',
  8. //...
  9. emit:['change'],
  10. emitPrefix: 'gi'
  11. },{// write the callback method directly in the rule
  12. field: 'goods_tag',
  13. //...
  14. on:{
  15. change:function() {
  16. //TODO
  17. }
  18. }
  19. }]
  1. <div id="app">
  2. <form-create :rule="rules" @goods-name-change="change" @gi-change="change"></form-create>
  3. </div>
  1. new vue({
  2. el:'#app',
  3. data: {
  4. Rules:rules
  5. },
  6. methods:{
  7. change:function(){
  8. //TODO
  9. }
  10. }
  11. })

emitPrefix

  • Type: Object
  • Description: Custom Prefix for component emit event
  • Default: Component field field

Template Rules

template component must set the parameters, other components do not need to be set

template

  • Type: string
  • Description: Generate template for template component

vm

  • Type: Vue|Function
  • Description: Vue sample object for template component for parsing template

General rules

props

  • Parameter: Object
  • Description: Set the component’s props

class

  • Parameter: Object|String|Array
  • Description: Set the class of the component

style

  • Parameter: Object|String
  • Description: Set the style of the component

attrs

  • Parameter: Object
  • Description: Set the normal HTML features of the component

domProps

  • Parameter: Object
  • Description: Set the DOM attribute of the component

on

  • Parameter: Object
  • Description: Set component events

nativeOn

  • Parameter: Object
  • Description: Native events of the listening component

directives

  • Parameter: Array
  • Description: Set custom instructions for components

scopedSlots

  • Parameter: Object
  • Description: Set the slot of the component

slot

  • Parameter: String
  • Description: Set the slot name of the component. If the component is a subcomponent of another component, specify a name for the slot.

Custom Configuration Item Description