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
e9aae8f7
Commit
e9aae8f7
authored
Jan 21, 2019
by
ileechee
Committed by
hetech
Jan 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tag: add click event (#14106)
* Tag: add tag click event handle * Tag: add doc and unit test.
parent
78f27d68
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
3 deletions
+36
-3
examples/docs/en-US/tag.md
examples/docs/en-US/tag.md
+1
-0
examples/docs/es/tag.md
examples/docs/es/tag.md
+1
-0
examples/docs/zh-CN/tag.md
examples/docs/zh-CN/tag.md
+2
-1
packages/tag/src/tag.vue
packages/tag/src/tag.vue
+5
-1
test/unit/specs/tag.spec.js
test/unit/specs/tag.spec.js
+27
-1
No files found.
examples/docs/en-US/tag.md
View file @
e9aae8f7
...
...
@@ -212,4 +212,5 @@ Besides default size, Tag component provides three additional sizes for you to c
### Events
| Event Name | Description | Parameters |
|---------- |-------- |---------- |
| click | triggers when Tag is clicked | — |
| close | triggers when Tag is removed | — |
\ No newline at end of file
examples/docs/es/tag.md
View file @
e9aae8f7
...
...
@@ -212,4 +212,5 @@ Además del tamaño predeterminado, el componente Tag proporciona tres tamaños
### Eventos
| Nombre | Descripción | Parametros |
| ------ | ------------------------------------ | ---------- |
| click | se disoara cuando el Tag es clic | — |
| close | se disoara cuando el Tag es removido | — |
\ No newline at end of file
examples/docs/zh-CN/tag.md
View file @
e9aae8f7
...
...
@@ -212,4 +212,5 @@ Tag 组件提供除了默认值以外的三种尺寸,可以在不同场景下
### Events
| 事件名称 | 说明 | 回调参数 |
|---------- |-------- |---------- |
| close | 关闭 Tag 时触发的事件 | — |
| click | 点击 Tag 时触发的事件 | — |
| close | 关闭 Tag 时触发的事件 | — |
\ No newline at end of file
packages/tag/src/tag.vue
View file @
e9aae8f7
...
...
@@ -14,6 +14,10 @@
handleClose
(
event
)
{
event
.
stopPropagation
();
this
.
$emit
(
'
close
'
,
event
);
},
handleClick
(
event
)
{
event
.
stopPropagation
();
this
.
$emit
(
'
click
'
,
event
);
}
},
computed
:
{
...
...
@@ -26,7 +30,7 @@
this
.
tagSize
?
`el-tag--
${
this
.
tagSize
}
`
:
''
,
{
'
is-hit
'
:
this
.
hit
}
];
const
tagEl
=
(
<
span
class
=
{
classes
}
style
=
{{
backgroundColor
:
this
.
color
}}
>
const
tagEl
=
(
<
span
class
=
{
classes
}
style
=
{{
backgroundColor
:
this
.
color
}}
on
-
click
=
{
this
.
handleClick
}
>
{
this
.
$slots
.
default
}
{
this
.
closable
&&
<
i
class
=
"
el-tag__close el-icon-close
"
on
-
click
=
{
this
.
handleClose
}
><
/i
>
...
...
test/unit/specs/tag.spec.js
View file @
e9aae8f7
...
...
@@ -82,9 +82,35 @@ describe('Tag', () => {
it
(
'
color
'
,
()
=>
{
vm
=
createVue
({
template
:
`
<el-tag color="rgb(0, 0, 0)"></el-tag>
<el-tag
ref="tag"
color="rgb(0, 0, 0)"></el-tag>
`
},
true
);
expect
(
vm
.
$el
.
style
.
backgroundColor
).
to
.
equal
(
'
rgb(0, 0, 0)
'
);
});
it
(
'
click
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-tag ref="tag" @click="handleClick">点击标签</el-tag>
`
,
data
()
{
return
{
clicksCount
:
0
};
},
methods
:
{
handleClick
()
{
this
.
clicksCount
=
this
.
clicksCount
+
1
;
}
}
},
true
);
let
tag
=
vm
.
$refs
.
tag
;
tag
.
$el
.
click
();
setTimeout
(
_
=>
{
expect
(
vm
.
clicksCount
).
to
.
be
.
equal
(
1
);
done
();
},
20
);
});
});
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