maker 组件生成器是用来生成组件规则的助手方法,通过链式操作即可快速生成对应的组件规则
获取 maker 生成器
浏览器
window.formCreate.maker
NodeJs
iview
import { maker } from 'form-create'
element 1.6.0+
import { maker } from 'form-create/element'
参数:{string|array} Json
、{bool} toMaker=false
用法:
let rules = maker.parse(json);
let rule = rules.find(field);
rule.value = 'value';
rule.event.click = function(){
//TODO
}
将 json 转换为生成规则,转换后可使用 find()方法快速查找指定field
字段
参数:{string} field
、{string|number} value
用法:
maker.hidden('field','value')
生成一个 hidden 组件
参考:hidden组件
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.input('field','title','value',{disabled:true})
生成一个 input 组件,type 默认为 text
参考:input组件
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.text('field','title','value',{disabled:true})
生成一个 input 组件,type 为 text
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.url('field','title','value',{disabled:true})
生成一个 input 组件,type 为 url
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.idate('field','title','value',{disabled:true})
生成一个 input 组件,type 为 date
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.password('field','title','value',{disabled:true})
生成一个 input 组件,type 为 password
参数:{string} field
、{string} title
、{number} value
、{object} props
用法:
maker.inputNumber('field','title','value',{disabled:true})
生成一个 inputNumber 组件,maker.number
是该方法的别名
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.autoComplete('field','title','xaboy',{data:['xaboy','github','xian']})
生成一个 autoComplete 组件,maker.auto
是该方法的别名
参数:{string} field
、{string} title
、{string|number} value
、{object} props
用法:
maker.radio('field','title',1)
.options([{value:1,label:'好用'},{value:2,label:'不好用',disabled:true}])
生成一个 radio 组件
参考:Radio 组件
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.checkbox('field','title',[1,2])
.options([{value:1,label:'高效'},{value:2,label:'简单'}])
生成一个 checkbox 组件
参考:checkbox 组件
参数:{string} field
、{string} title
、{string|number|array} value
、{object} props
用法:
maker.select('field','title',1)
.options([{value:1,label:'高效'},{value:2,label:'简单'}])
生成一个 select 组件,props.multiple
默认为 false
参考:select 组件
参数:{string} field
、{string} title
、{string|number} value
、{object} props
用法:
maker.selectOne('field','title',1)
.options([{value:1,label:'高效'},{value:2,label:'简单'}])
生成一个 select 组件,props.multiple
为 false
即为单选的下拉选择框
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.selectMultiple('field','title',[1,2])
.options([{value:1,label:'高效'},{value:2,label:'简单'}])
生成一个 select 组件,props.multiple
为 true
即为可多选的下拉选择框
参数:{string} field
、{string} title
、{string|number} value
、{object} props
用法:
maker.switch('field','title',1,{trueValue:1,falseValue:0})
生成一个 switch 组件
参考:switch 组件
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.cascader('field','title',[],{data:[]})
生成一个 cascader 组件
参数:{string} field
、{string} title
、{array|string|date} value
、{object} props
用法:
maker.datePicker('field','title','2018-12-16')
生成一个 datePicker 组件,type
默认为 date
参数:{string} field
、{string} title
、{date|string} value
、{object} props
用法:
maker.date('field','title','2018-12-16')
生成一个 datePicker 组件,type
为 date
,可选择日期
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.dateRange('field','title',['2018-11-30','2018-12-16'])
生成一个 datePicker 组件,type
为 dateRange
,可选择日期区间
参数:{string} field
、{string} title
、{date|string} value
、{object} props
用法:
maker.dateTime('field','title','2018-12-16 23:23:23')
生成一个 datePicker 组件,type
为 dateTime
,可选择日期+时间
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.dateTimeRange('field','title',['2018-11-30 23:23:23','2018-12-16 23:23:23'])
生成一个 datePicker 组件,type
为 dateTimeRange
,可选择日期+时间区间
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.year('field','title','2018-12-16')
生成一个 datePicker 组件,type
为 year
,可选择年份
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.dateRange('field','title','2018-12-16')
生成一个 datePicker 组件,type
为 month
,可选择月份
参数:{string} field
、{string} title
、{array|string|date} value
、{object} props
用法:
maker.timePicker('field','title','23:23:23')
生成一个 timePicker 组件,type
默认为 time
参数:{string} field
、{string} title
、{string|date} value
、{object} props
用法:
maker.timePicker('field','title','23:23:23')
生成一个 timePicker 组件,type
为 time
,可选择时间
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.timePicker('field','title',['23:23:23','23:59:59'])
生成一个 timePicker 组件,type
默认为 time
,可选择时间区间
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.colorPicker('field','title','#FF7271')
生成一个 colorPicker 组件,maker.color
是该方法的别名
参数:{string} field
、{string} title
、{string|array} value
、{object} props
用法:
maker.upload('field','title','image1.png',{action:'upload.php',maxLength:1})
生成一个 upload 组件,type
默认为 field
参考:upload 组件
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.uploadImage('field','title',['image1.png'.'image2.png'],{action:'upload.php'})
生成一个 upload 组件,type
为 image
,maker.image
是该方法的别名
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.uploadFile('field','title',['image1.png'.'image2.png'],{action:'upload.php'})
生成一个 upload 组件,type
为 file
,maker.file
是该方法的别名
参数:{string} field
、{string} title
、{string|array} value
、{object} props
用法:
maker.uploadImageOne('field','title','image1.png',{action:'upload.php'})
生成一个 upload 组件,type
为 image
且maxLength
为1
只能上传一张图片
maker.imageOne
是该方法的别名
参数:{string} field
、{string} title
、{string} value
、{object} props
用法:
maker.uploadFileOne('field','title','image1.png',{action:'upload.php'})
生成一个 upload 组件,type
为 file
且maxLength
为1
只能上传一个文件
maker.fileOne
是该方法的别名
参数:{string} field
、{string} title
、{number} value
、{object} props
用法:
maker.rate('field','title',10)
生成一个 rate 组件
参考:rate 组件
参数:{string} field
、{string} title
、{number} value
、{object} props
用法:
maker.slider('field','title',10)
生成一个 slider 组件,props.range
默认为false
参考:slider 组件
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.sliderRange('field','title',[10,100])
生成一个 slider 组件,props.range
为true
,可选择区间
参数:{string} field
、{string} title
、{array} value
、{object} props
用法:
maker.tree('field','title',[12,13],{data:[]})
生成一个 tree 组件
参考:tree 组件
相关方法:
maker.treeSelected
maker.treechecked