import { Injectable } from '@angular/core' @Injectable({ providedIn: 'root' }) export class ControlersService { private componentList: Array<{ key: string; cmf: any; type: any }> = [] add(key: string, cmf: any, type: any) { const isContain = this.componentList && this.componentList.some(el => el.key === key) if (!isContain) { this.componentList.push({ key, cmf, type }) } else { throw new Error('存在同名key实例!') } } get(key: string) { return this.componentList.find(el => el.key === key) } } export enum ComponentType { Text = 1, Lookup = 2, Image = 3, Others = 4 }