radio 单选框
radio 单选框
单选框。
代码演示
基础样例
最简单的用法。
import { Component } from '@angular/core';import { SFSchema, SFRadioWidgetSchema } from '@delon/form';import { NzMessageService } from 'ng-zorro-antd/message';import { of } from 'rxjs';import { delay } from 'rxjs/operators';@Component({ selector: 'form-radio-simple', template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,})export class FormRadioSimpleComponent { schema: SFSchema = { properties: { btn: { type: 'string', title: 'Button', enum: ['A', 'B', 'C'], ui: { widget: 'radio', styleType: 'button', buttonStyle: 'solid', } as SFRadioWidgetSchema, default: 'A', }, // 异步数据 async: { type: 'string', title: 'Async', ui: { widget: 'radio', asyncData: () => of([{ label: '男', value: 'M' }, { label: '女', value: 'F' }, { label: '未知', value: 'N' }]).pipe(delay(100)), change: console.log, } as SFRadioWidgetSchema, default: 'N', }, }, }; constructor(public msg: NzMessageService) {} submit(value: any) { this.msg.success(JSON.stringify(value)); }}
API
schema 属性
| [enum] |
数据源 |
SFSchemaEnumType[] |
- |
|
|
|
|
| [readOnly] |
禁用状态 |
boolean |
- |
|
|
|
|
ui 属性
| [asyncData] |
异步数据源 |
() => Observable<SFSchemaEnumType[]> |
- |
|
|
|
|
| [size] |
大小,等同 nzSize |
string |
- |
|
|
|
|
| [styleType] |
radio 的样式 |
default, button |
default |
|
|
|
|
| [change] |
值变更事件 |
(res: SFValue) => void |
- |
|
|
|
|
| [buttonStyle] |
RadioButton 的风格样式,目前有描边和填色两种风格 |
‘outline’|’solid’ |
‘outline’ |
|
|
|
|