如何处理Formio自定义“按钮”控件的单击事件?

时间:2019-01-09 10:27:54

标签: formio

我已经下载了formiojs的源代码,并尝试进行一些自定义。 我需要“按钮”控件,但是当我单击它时,我想更改按钮上的左侧图标和文本。我已经试过了这段代码,但是对我没有帮助:

export default class UserNameComponent extends BaseComponent {
  static schema(...extend) {
    return BaseComponent.schema({
      type: 'button',
      label: 'UserName',
      key: 'username',
      size: 'md',
      leftIcon: 'fa fa-user',
      rightIcon: '',
      block: false,
      action: 'custom',
      custom: 'if(component.label === "UserName")' +
          '{ component.label = "Alex Alex"; component.leftIcon = "fa fa-trash"; }' +
          'else' +
          '{ component.label = "UserName"; component.leftIcon = "fa fa-user"; }',
      persistent: false,
      disableOnInvalid: false,
      theme: 'default',
      dataGridLabel: true
    }, ...extend);
  }

我该怎么做?

0 个答案:

没有答案