TagEllipsis.vue
787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script>
export default {
name: 'TagEllipsis',
components: {},
props: {
list: {
type: Array,
default: () => []
},
limit: {
type: [String, Number],
default: 2
},
defaultProps: {
type: String,
default: 'name'
}
},
data() {
return {}
},
computed: {},
watch: {},
created() {},
mounted() {},
methods: {}
}
</script>
<template>
<div class="tag-ellipsis">
<template v-for="(item, index) in list">
<el-tag size="medium" v-if="index < limit" :key="index">
{{ item[defaultProps] || item }}
</el-tag>
</template>
<el-tag v-if="list.length && list.length > limit">...</el-tag>
</div>
</template>
<style lang="scss" scoped>
.tag-ellipsis {
display: inline-block;
}
</style>