ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
58 lines (49 loc) • 1.07 kB
Markdown
title:
zh-CN: 基础样例
en-US: Basic Usage
order: 0
## zh-CN
最简单的用法。
## en-US
Simplest of usage.
```ts
import { Component } from '@angular/core';
import { SFRateWidgetSchema, SFSchema } from '@ohayo/form';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-demo',
template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
})
export class DemoComponent {
schema: SFSchema = {
properties: {
rate: {
type: 'number',
title: '评级',
default: 4.5,
ui: {
widget: 'rate',
} as SFRateWidgetSchema,
},
// 允许半选
rate2: {
type: 'number',
title: '评级',
maximum: 5,
multipleOf: 0.5,
default: 4.5,
ui: {
widget: 'rate',
text: '{{value}} starts',
} as SFRateWidgetSchema,
},
},
};
constructor(private msg: NzMessageService) {}
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}
```