Actuator 主要用于 options 参数的解析与执行。
def 与外部传入的 options 进行合并,计算出最终的 options。const actuator = new Actuator({
options: {},
def: {
getBaseConfig () {
return {
title: '',
idKey: 'id'
}
},
}
})
options 外部options。def 默认options。def.getBaseConfig 默认options.getBaseConfig。初始化 config 。
执行 def.getBaseConfig(nvt) 和 options.getBaseConfig(nvt) 并将结果进行 mergeObject,计算出最终的 config。
this.actuator.initConfig(nvt)
用于检查 options 中的回调函数是否存在。
const options = {
getDataList: () => []
}
this.actuator.has('getDataList')
// => true
this.actuator.has('getDataListSync')
// => false
用于触发 options 中的回调函数。
const options = {
getDefaultParams: (value) => {
return value
},
hasDefaultParams: true
}
this.actuator.dispatch('getDefaultParams', false)
// => false
this.actuator.dispatch('hasDefaultParams')
// => true
获取最终的 options 。
this.actuator.getOptions()
用于获取 config 。
this.actuator.getConfig()
用于获取 config 中的某一个字段。
// 获取 options.getBaseConfig() 返回值中的 icon 字段。
this.actuator.getConfigBy('icon')