多行文本框

一般用于多行字符串。

代码演示

基础样例

最简单的用法。

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

import { DelonFormModule, SFSchema, SFTextareaWidgetSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
  selector: 'form-textarea-simple',
  template: ` <sf [schema]="schema" (formSubmit)="submit($event)" /> `,
  standalone: true,
  imports: [DelonFormModule]
})
export class FormTextareaSimpleComponent {
  private readonly msg = inject(NzMessageService);
  schema: SFSchema = {
    properties: {
      remark: {
        type: 'string',
        title: '描述',
        ui: {
          widget: 'textarea',
          autosize: { minRows: 2, maxRows: 6 },
          change: val => console.log('change', val),
          focus: ev => console.log('focus', ev),
          blur: ev => console.log('blur', ev)
        } as SFTextareaWidgetSchema
      },
      max: {
        type: 'string',
        title: 'Max',
        ui: {
          widget: 'textarea',
          maxCharacterCount: 100
        } as SFTextareaWidgetSchema
      }
    }
  };

  submit(value: {}): void {
    this.msg.success(JSON.stringify(value));
  }
}

API

schema属性

成员说明类型默认值
[maxLength]表单最大长度number-
[readOnly]禁用状态boolean-

ui属性

成员说明类型默认值
[size]大小,等同 nzSizestring-
[placeholder]在文字框中显示提示讯息string-
[autosize]自适应内容高度,可设置为 true|false 或对象:{ minRows: 2, maxRows: 6 }Boolean|Objecttrue
[borderless]是否隐藏边框booleanfalse
[maxCharacterCount]textarea 数字提示显示的最大值number-
[computeCharacterCount]自定义计算 characterCount 的函数(v: string) => numberv => v.length
[change]内容变更事件(val: string) => void-
[focus]焦点事件(e: FocusEvent) => void-
[blur]失焦事件(e: FocusEvent) => void-
Loading...