Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
afb6625d
Commit
afb6625d
authored
May 10, 2017
by
pengchongfu
Committed by
baiyaaaaa
May 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputNumber: improve user experience when typing, fix #4661 (#4712)
parent
57f159cf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
examples/docs/en-US/input-number.md
examples/docs/en-US/input-number.md
+1
-0
examples/docs/zh-CN/input-number.md
examples/docs/zh-CN/input-number.md
+1
-0
packages/input-number/src/input-number.vue
packages/input-number/src/input-number.vue
+20
-2
No files found.
examples/docs/en-US/input-number.md
View file @
afb6625d
...
...
@@ -126,6 +126,7 @@ Additional `large` and `small` sizes of the input box are available
|size | size of the component | string | large/small| — |
|disabled| whether the component is disabled | boolean | — | false |
|controls| whether to enable the control buttons | boolean | — | true |
|debounce| debounce delay when typing, in millisecond | number | — | 300 |
### Events
...
...
examples/docs/zh-CN/input-number.md
View file @
afb6625d
...
...
@@ -131,6 +131,7 @@
| size | 计数器尺寸 | string | large, small | — |
| disabled | 是否禁用计数器 | boolean | — | false |
| controls | 是否使用控制按钮 | boolean | — | true |
| debounce | 输入时的去抖延迟,毫秒 | number | — | 300 |
### Events
| 事件名称 | 说明 | 回调参数 |
...
...
packages/input-number/src/input-number.vue
View file @
afb6625d
...
...
@@ -27,7 +27,7 @@
@
keydown.up.native.prevent=
"increase"
@
keydown.down.native.prevent=
"decrease"
@
blur=
"handleBlur"
@
input=
"
h
andleInput"
@
input=
"
debounceH
andleInput"
:disabled=
"disabled"
:size=
"size"
:max=
"max"
...
...
@@ -46,6 +46,7 @@
<
script
>
import
ElInput
from
'
element-ui/packages/input
'
;
import
{
once
,
on
}
from
'
element-ui/src/utils/dom
'
;
import
debounce
from
'
throttle-debounce/debounce
'
;
export
default
{
name
:
'
ElInputNumber
'
,
...
...
@@ -96,6 +97,10 @@
controls
:
{
type
:
Boolean
,
default
:
true
},
debounce
:
{
type
:
Number
,
default
:
300
}
},
data
()
{
...
...
@@ -177,17 +182,30 @@
const
oldVal
=
this
.
currentValue
;
if
(
newVal
>=
this
.
max
)
newVal
=
this
.
max
;
if
(
newVal
<=
this
.
min
)
newVal
=
this
.
min
;
if
(
oldVal
===
newVal
)
return
;
if
(
oldVal
===
newVal
)
{
this
.
$refs
.
input
.
setCurrentValue
(
this
.
currentValue
);
return
;
}
this
.
$emit
(
'
change
'
,
newVal
,
oldVal
);
this
.
$emit
(
'
input
'
,
newVal
);
this
.
currentValue
=
newVal
;
},
handleInput
(
value
)
{
if
(
value
===
''
)
{
return
;
}
const
newVal
=
Number
(
value
);
if
(
!
isNaN
(
newVal
))
{
this
.
setCurrentValue
(
newVal
);
}
else
{
this
.
$refs
.
input
.
setCurrentValue
(
this
.
currentValue
);
}
}
},
created
()
{
this
.
debounceHandleInput
=
debounce
(
this
.
debounce
,
value
=>
{
this
.
handleInput
(
value
);
});
}
};
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment