Global API
create
Type:
FunctionParameter:
ArrayrulesObjectoptions
return value:
Object$f
Description: Generate form
Usage:
const $f = formCreate.create(rules,options);
init
Type:
FunctionParameter:
ArrayrulesObjectoptions
return value:
Functionmount mount formFunctionremove remove formFunctiondestroy destroys the formObject$f
Description: Create a form constructor
Usage:
const {$f,mount,remove,destroy} = formCreate.init(rules,options);//mount the form to #appmount(document.getElementById('app'));//Destroy the formremove();
component
Type:
FunctionParameter:
stringidObjectcomponent
Description: Mount custom components in form-create
Usage:
//mount componentformCreate.component('test',component);//get the componentconst component = formCreate.component('test');
createParser
Type:
Functionreturn value:
Parserparser
Description: Create a new component parser
Usage:
const Parser = formCreate.createParser();
setParser
Type:
FunctionParameter:
stringcomponentNameParserparser
Description: Bind a component parser
Usage:
const Parser = formCreate.createParser();parser.prototype.toFormValue = (value)=>parseFloat(value)||0;formCreate.setParser('inputNumber',Parser);
maker
type:
ObjectDescription: Component Builder
Usage:
rule = maker.input('testTitle','testField','testValue');
$form
Type:
FunctionDescription: Bind a component parser
Usage:
$formCreate = formCreate.$form();//Local mount formCreatenew vue({components:{'form-create': $formCreate}});//Global mountVue.component('form-create',$formCreate);
parseJson
Type:
FunctionParameter:
StringjsonBooleanmode
Description: Convert json to a generation rule, add a second parameter for backward compatibility, use the new version to parse when
mode: true(version> 1.0.5 recommends that the second parameter is fixed to true)Usage:
const json = $f.toJson();const rule = formCreate.parseJson(json, true);
Event
change
Parameter:
fieldvalue$fapi
Directions: Triggered when the value of the form component changes within the component
set-value
Parameter:
fieldvalue$fapi
Directions: Triggered when the value of the form component modified externally
emit-event
Parameter:
emitName...argsevent Parameter
Directions: Triggered when the component’s
emitevent triggered
control
Parameter:
rulerule$fapi
Directions: Triggered when the component’s
controlbecomes effective or invalid
mounted
Parameter:
$fapi
Directions: Triggered after the form rendered for the first time
on-submit
Parameter:
formData$fapi
Directions: Triggered when the form submit button clicked
vm.$formCreate
Type:
FunctionParameter:
ArrayrulesObjectoptions
return value:
Object$f
Attributes:
FunctioncomponentFunctioncreateParserFunctionsetParserFunction$formFunctionparseJsonObjectmaker
Description: Generate form
Usage:
new vue({mounted(){Const $f = this.$formCreate(rules,options);}})
