initEventBtns()

in src/setter/events-setter/index.tsx [99:146]


  initEventBtns() {
    const { definition } = this.props;
    let isRoot = false;
    let isCustom = false;
    let eventBtns = [];
    definition.map((item) => {
      if (item.type === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT) {
        isRoot = true;
      }

      if (item.type === DEFINITION_EVENT_TYPE.EVENTS) {
        isCustom = true;
      }

      return item;
    });

    if (isRoot) {
      eventBtns = [
        {
          value: EVENT_CONTENTS.LIFE_CYCLE_EVENT,
          label: '生命周期',
        },
      ];
    } else if (isCustom) {
      eventBtns = [
        {
          value: EVENT_CONTENTS.COMPONENT_EVENT,
          label: '组件自带事件',
        },
      ];
    } else {
      eventBtns = [
        {
          value: EVENT_CONTENTS.NATIVE_EVENT,
          label: '原生事件',
        },
      ];
    }

    this.setState(
      {
        eventBtns,
        isRoot,
      },
      this.initLifeCycleEventDataList,
    );
  }