@@ -48,16 +78,13 @@ Used for marking and selection.
...
@@ -48,16 +78,13 @@ Used for marking and selection.
### Removable Tag
### Removable Tag
:::demo Set the `closable` attribute to define a removable tag. It accepts a `Boolean`. By default the removal of Tag has a fading animation. If you don't want to use it, you can set the `close-transition` attribute, which accepts a `Boolean`, to `true`. `close` event triggers when Tag is removed.
:::demo `closable` attribute can be used to define a removable tag. It accepts a `Boolean`. By default the removal of Tag has a fading animation. If you don't want to use it, you can set the `close-transition` attribute, which accepts a `Boolean`, to `true`. `close` event triggers when Tag is removed.
```html
```html
<el-tag
<el-tag
v-for="tag in tags"
v-for="tag in tags"
:closable="true"
:closable="true"
:type="tag.type"
:type="tag.type"
:key="tag"
:close-transition="false"
@close="handleClose(tag)"
>
>
{{tag.name}}
{{tag.name}}
</el-tag>
</el-tag>
...
@@ -67,18 +94,70 @@ Used for marking and selection.
...
@@ -67,18 +94,70 @@ Used for marking and selection.
data(){
data(){
return{
return{
tags:[
tags:[
{key:1,name:'Tag One',type:''},
{name:'Tag 1',type:''},
{key:2,name:'Tag Two',type:'gray'},
{name:'Tag 2',type:'gray'},
{key:5,name:'Tag Three',type:'primary'},
{name:'Tag 3',type:'primary'},
{key:3,name:'Tag Four',type:'success'},
{name:'Tag 4',type:'success'},
{key:4,name:'Tag Five',type:'warning'},
{name:'Tag 5',type:'warning'},
{key:6,name:'Tag Six',type:'danger'}
{name:'Tag 6',type:'danger'}
]
]
};
};
}
}
</script>
```
:::
### Edit Dynamically
You can use the `close` event to add and remove tag dynamically.
:::demo
```html
<el-tag
v-for="tag in dynamicTags"
:closable="true"
:close-transition="false"
@close="handleClose(tag)"
>
{{tag}}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-buttonv-elseclass="button-new-tag"size="small"@click="showInput">+ New Tag</el-button>