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
e70c598d
Commit
e70c598d
authored
Mar 04, 2018
by
blackmiaool
Committed by
杨奕
Mar 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input: add clear event (#9988)
parent
657f9b9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
examples/docs/en-US/input.md
examples/docs/en-US/input.md
+1
-0
examples/docs/zh-CN/input.md
examples/docs/zh-CN/input.md
+1
-0
packages/input/src/input.vue
packages/input/src/input.vue
+1
-0
test/unit/specs/input.spec.js
test/unit/specs/input.spec.js
+31
-0
No files found.
examples/docs/en-US/input.md
View file @
e70c598d
...
...
@@ -682,6 +682,7 @@ Search data from server-side.
| blur | triggers when Input blurs | (event: Event) |
| focus | triggers when Input focuses | (event: Event) |
| change | triggers when the icon inside Input value change | (value: string
\|
number) |
| clear | triggers when the Input is cleared by the button which generated by the "clearable" attribute | (event: Event) |
### Autocomplete Attributes
...
...
examples/docs/zh-CN/input.md
View file @
e70c598d
...
...
@@ -836,6 +836,7 @@ export default {
| blur | 在 Input 失去焦点时触发 | (event: Event) |
| focus | 在 Input 获得焦点时触发 | (event: Event) |
| change | 在 Input 值改变时触发 | (value: string
\|
number) |
| clear | 在点击"clearable"属性生成的清空按钮时触发 | (event: Event) |
### Input Methods
| 方法名 | 说明 | 参数 |
...
...
packages/input/src/input.vue
View file @
e70c598d
...
...
@@ -284,6 +284,7 @@
clear
()
{
this
.
$emit
(
'
input
'
,
''
);
this
.
$emit
(
'
change
'
,
''
);
this
.
$emit
(
'
clear
'
);
this
.
setCurrentValue
(
''
);
this
.
focus
();
}
...
...
test/unit/specs/input.spec.js
View file @
e70c598d
...
...
@@ -241,5 +241,36 @@ describe('Input', () => {
done
();
});
});
it
(
'
event:clear
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-input
ref="input"
placeholder="请输入内容"
clearable
:value="input">
</el-input>
`
,
data
()
{
return
{
input
:
'
a
'
};
}
},
true
);
const
spyClear
=
sinon
.
spy
();
const
inputElm
=
vm
.
$el
.
querySelector
(
'
input
'
);
// focus to show clear button
inputElm
.
focus
();
vm
.
$refs
.
input
.
$on
(
'
clear
'
,
spyClear
);
vm
.
$nextTick
(
_
=>
{
vm
.
$el
.
querySelector
(
'
.el-input__clear
'
).
click
();
vm
.
$nextTick
(
_
=>
{
expect
(
spyClear
.
calledOnce
).
to
.
be
.
true
;
done
();
});
});
});
});
});
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