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
a3dca68f
Commit
a3dca68f
authored
Mar 22, 2017
by
pengchongfu
Committed by
杨奕
Mar 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Select: add delete-tag event (#3632)
parent
d408ad3c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
1 deletion
+64
-1
examples/docs/en-US/select.md
examples/docs/en-US/select.md
+1
-0
examples/docs/zh-CN/select.md
examples/docs/zh-CN/select.md
+1
-0
packages/select/src/select.vue
packages/select/src/select.vue
+2
-1
test/unit/specs/select.spec.js
test/unit/specs/select.spec.js
+60
-0
No files found.
examples/docs/en-US/select.md
View file @
a3dca68f
...
@@ -647,6 +647,7 @@ Create and select new items that are not included in select options
...
@@ -647,6 +647,7 @@ Create and select new items that are not included in select options
|---------|---------|---------|
|---------|---------|---------|
| change | triggers when the selected value changes | current selected value |
| change | triggers when the selected value changes | current selected value |
| visible-change | triggers when the dropdown appears/disappears | true when it appears, and false otherwise |
| visible-change | triggers when the dropdown appears/disappears | true when it appears, and false otherwise |
| delete-tag | triggers when deletes tag in multiple mode | deleted tag value |
### Option Group Attributes
### Option Group Attributes
| Attribute | Description | Type | Accepted Values | Default |
| Attribute | Description | Type | Accepted Values | Default |
...
...
examples/docs/zh-CN/select.md
View file @
a3dca68f
...
@@ -648,6 +648,7 @@
...
@@ -648,6 +648,7 @@
|---------|---------|---------|
|---------|---------|---------|
| change | 选中值发生变化时触发 | 目前的选中值 |
| change | 选中值发生变化时触发 | 目前的选中值 |
| visible-change | 下拉框出现/隐藏时触发 | 出现则为 true,隐藏则为 false |
| visible-change | 下拉框出现/隐藏时触发 | 出现则为 true,隐藏则为 false |
| delete-tag | 多选模式下删除tag时触发 | 删除的tag值 |
### Option Group Attributes
### Option Group Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
...
...
packages/select/src/select.vue
View file @
a3dca68f
...
@@ -599,7 +599,8 @@
...
@@ -599,7 +599,8 @@
deleteTag
(
event
,
tag
)
{
deleteTag
(
event
,
tag
)
{
let
index
=
this
.
selected
.
indexOf
(
tag
);
let
index
=
this
.
selected
.
indexOf
(
tag
);
if
(
index
>
-
1
&&
!
this
.
disabled
)
{
if
(
index
>
-
1
&&
!
this
.
disabled
)
{
this
.
value
.
splice
(
index
,
1
);
let
deletedTag
=
this
.
value
.
splice
(
index
,
1
)[
0
];
this
.
$emit
(
'
delete-tag
'
,
deletedTag
);
}
}
event
.
stopPropagation
();
event
.
stopPropagation
();
},
},
...
...
test/unit/specs/select.spec.js
View file @
a3dca68f
...
@@ -442,6 +442,66 @@ describe('Select', () => {
...
@@ -442,6 +442,66 @@ describe('Select', () => {
},
100
);
},
100
);
});
});
it
(
'
multiple delete-tag
'
,
done
=>
{
sinon
.
stub
(
window
.
console
,
'
log
'
);
vm
=
createVue
({
template
:
`
<div>
<el-select v-model="value" multiple @delete-tag="handleDeleteTag">
<el-option
v-for="item in options"
:label="item.label"
:value="item.value">
<p>{{item.label}} {{item.value}}</p>
</el-option>
</el-select>
</div>
`
,
data
()
{
return
{
options
:
[{
value
:
'
选项1
'
,
label
:
'
黄金糕
'
},
{
value
:
'
选项2
'
,
label
:
'
双皮奶
'
},
{
value
:
'
选项3
'
,
label
:
'
蚵仔煎
'
},
{
value
:
'
选项4
'
,
label
:
'
龙须面
'
},
{
value
:
'
选项5
'
,
label
:
'
北京烤鸭
'
}],
value
:
[
'
选项1
'
,
'
选项3
'
]
};
},
methods
:
{
handleDeleteTag
()
{
console
.
log
(
'
delete tag
'
);
}
}
},
true
);
const
tagCloseIcons
=
vm
.
$el
.
querySelectorAll
(
'
.el-tag__close
'
);
expect
(
vm
.
value
.
length
).
to
.
equal
(
2
);
tagCloseIcons
[
1
].
click
();
setTimeout
(()
=>
{
expect
(
vm
.
value
.
length
).
to
.
equal
(
1
);
expect
(
window
.
console
.
log
.
callCount
).
to
.
equal
(
1
);
tagCloseIcons
[
0
].
click
();
setTimeout
(()
=>
{
expect
(
vm
.
value
.
length
).
to
.
equal
(
0
);
expect
(
window
.
console
.
log
.
callCount
).
to
.
equal
(
2
);
window
.
console
.
log
.
restore
();
done
();
},
100
);
},
100
);
});
it
(
'
multiple limit
'
,
done
=>
{
it
(
'
multiple limit
'
,
done
=>
{
vm
=
getSelectVm
({
multiple
:
true
,
multipleLimit
:
1
});
vm
=
getSelectVm
({
multiple
:
true
,
multipleLimit
:
1
});
const
options
=
vm
.
$el
.
querySelectorAll
(
'
.el-select-dropdown__item
'
);
const
options
=
vm
.
$el
.
querySelectorAll
(
'
.el-select-dropdown__item
'
);
...
...
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