range 滑动输入条
range 滑动输入条
滑动型输入器,展示当前值和可选范围。
注意事项
- 强制忽略 exclusiveMinimum、exclusiveMaximum
代码演示
基础样例
最简单的用法。
import { Component } from '@angular/core';import { SFSchema, SFSliderWidgetSchema } from '@delon/form';import { NzMessageService } from 'ng-zorro-antd/message';@Component({ selector: 'form-slider-simple', template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,})export class FormSliderSimpleComponent { schema: SFSchema = { properties: { count: { type: 'number', title: '数量', ui: { widget: 'slider', } as SFSliderWidgetSchema, default: 10, }, // 双滑块模式 range: { type: 'number', title: '范围', ui: { widget: 'slider', range: true, } as SFSliderWidgetSchema, default: [10, 20], }, }, }; constructor(public msg: NzMessageService) {} submit(value: any) { this.msg.success(JSON.stringify(value)); }}
API
schema 属性
ui 属性
| [range] |
当添加该属性时,启动双滑块模式 |
Boolean |
- |
|
|
|
|
| [dots] |
是否只能拖拽到刻度上 |
Boolean |
false |
|
|
|
|
| [included] |
是否包含。marks 不为空对象时有效,值为 true 时表示值为包含关系,false 表示并列 |
Boolean |
true |
|
|
|
|
| [vertical] |
竖直显示。添加该属性时,Slider 为垂直方向。 |
boolean |
false |
|
|
|
|
| [afterChange] |
与 onmouseup 触发时机一致,把当前值作为参数传入。 |
(value: NzSliderValue) => void |
- |
|
|
|
|
| [formatter] |
Slider 会把当前值传给 nzTipFormatter,并在 Tooltip 中显示 nzTipFormatter 的返回值,若为 null,则隐藏 Tooltip |
(value: number) => string |
- |
|
|
|
|