tag 标签

tag 标签

进行标记和分类的小标签,注: 只支持 checkable 标签模式。

代码演示

基础样例

最简单的用法。

import { Component } from '@angular/core';import { SFSchema, SFTagWidgetSchema } from '@delon/form';import { NzMessageService } from 'ng-zorro-antd/message';import { of } from 'rxjs';import { delay } from 'rxjs/operators';@Component({  selector: 'form-tag-simple',  template: `    <​sf [schema]="schema" (formSubmit)="submit($event)"><​/sf>  `,})export class FormTagSimpleComponent {  schema: SFSchema = {    properties: {      like: {        type: 'number',        title: '兴趣',        enum: [{ value: 1, label: '电影' }, { value: 2, label: '书' }, { value: 3, label: '旅行' }],        ui: {          widget: 'tag',        } as SFTagWidgetSchema,        default: [1, 2],      },      like1: {        type: 'number',        title: '兴趣',        ui: {          widget: 'tag',          asyncData: () => of([{ value: 1, label: '电影' }, { value: 2, label: '书' }, { value: 3, label: '旅行' }]).pipe(delay(10)),        } as SFTagWidgetSchema,        default: [1, 2],      },    },  };  constructor(public msg: NzMessageService) {}  submit(value: any) {    this.msg.success(JSON.stringify(value));  }}

API

schema 属性

成员 说明 类型 默认值
[enum] 数据源 SFSchemaEnumType[] -

ui 属性

成员 说明 类型 默认值
[asyncData] 异步数据源 () => Observable<​SFSchemaEnumType[]> -
[mode] 设定标签工作的模式 ‘closeable’|’default’|’checkable’ ‘checkable’
[onClose] 关闭时的回调,在 nzMode=”closable” 时可用 (e:MouseEvent) => void -
[checkedChange] 设置标签的选中状态的回调 (status: boolean) => void -