diff --git a/components/input-item/custom-input/custom-input.component.ts b/components/input-item/custom-input/custom-input.component.ts index 1c551ff0..e97b4bdd 100644 --- a/components/input-item/custom-input/custom-input.component.ts +++ b/components/input-item/custom-input/custom-input.component.ts @@ -212,6 +212,11 @@ export class CustomInputComponent implements OnInit, OnDestroy { } onKeyboardClick = keyboardItemValue => { + // 只允许一个小数点且不能是首位 + if (keyboardItemValue === '.' && (this._value.includes('.') || this._value === '')) { + return; + } + let valueAfterChange; // 删除键 if (keyboardItemValue === 'delete') { diff --git a/components/input-item/demo/basic.ts b/components/input-item/demo/basic.ts index fefe0180..dfa90c1b 100644 --- a/components/input-item/demo/basic.ts +++ b/components/input-item/demo/basic.ts @@ -4,9 +4,8 @@ import { ToastService } from 'ng-zorro-antd-mobile'; @Component({ selector: 'demo-input-item-basic', template: ` -