文本

一般用于直接显示文本。

规则

  • 强制取消 required 效果

  • 若不指定 defaultText 值不存在时自动渲染 -

代码演示

基础样例

最简单的用法。

expand code expand code
import { Component, inject } from '@angular/core';

import { YelonFormModule, SFSchema, SFStringWidgetSchema, SFTextWidgetSchema } from '@yelon/form';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
  selector: 'form-text-simple',
  template: ` <sf [schema]="schema" [loading]="loading" (formSubmit)="submit($event)" /> `,
  standalone: true,
  imports: [YelonFormModule]
})
export class FormTextSimpleComponent {
  private readonly msg = inject(NzMessageService);
  loading = false;
  schema: SFSchema = {
    properties: {
      id1: { type: 'number', ui: { widget: 'text' } as SFTextWidgetSchema },
      id2: { type: 'number', ui: { widget: 'text', defaultText: 'default text' } as SFTextWidgetSchema },
      name: {
        type: 'string',
        title: 'Name',
        ui: {
          addOnAfter: 'RMB',
          placeholder: 'RMB结算'
        } as SFStringWidgetSchema
      }
    },
    required: ['name']
  };

  submit(value: {}): void {
    this.loading = true;
    setTimeout(() => {
      this.loading = false;
      this.msg.success(JSON.stringify(value));
    }, 1000);
  }
}

API

ui属性

参数说明类型默认值
[defaultText]当值不存在时所指定的文本string-
[html]是否支持HTMLbooleantrue
Loading...