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: ` -
-
Basic
-
+
+
Money input
@@ -41,7 +40,7 @@ import { ToastService } from 'ng-zorro-antd-mobile';
-
+
Customize to focus
@@ -66,7 +65,7 @@ import { ToastService } from 'ng-zorro-antd-mobile';
-
+
Click label to focus input
@@ -76,13 +75,13 @@ import { ToastService } from 'ng-zorro-antd-mobile';
-
+
Show clear
-
+
Number of words for the title
-
+
Custom title(text / image / empty)
@@ -107,13 +106,13 @@ import { ToastService } from 'ng-zorro-antd-mobile';
-
+
Customize the extra content in the right
- +
-
+
Format
@@ -127,19 +126,19 @@ import { ToastService } from 'ng-zorro-antd-mobile';
-
+
Not editable / Disabled
-
+
Confirm when typing