# Custom form components

Components that implement v-model can be called form components

# Example

Customize the counter button component to get the number of button clicks. The function of this component is the same as the built-in component

# Predefined

Define the following properties and events to achieve the same effect as the built-in components. Give it a try.

props

Receive some properties through props inside the custom component

  • value Component value
  • disabled Disabled state of the component

例如:

vm = Vue({
  props:{
   value:String,
   disabled:Boolean      
  }
})

Input event

Update the internal value of the component through the input event

When the component value changes, update the value through the input event. For example:

vm.$emit('input',newValue)

# Mount custom components

The custom component to be generated must be mounted globally via the vue.component method, or mounted via the form Create.component method

for example:

formCreate.component('TestComponent',component)

# Generate

The form component must define the field attribute

JSON

{
    type:'TestComponent',
    value:'test',
    field:'testField',
    title:'title'
}

Maker

formCreate.maker.create('TestComponent','testField','title').value('test')

Now this custom component can be operated like the built-in component