2024-02-23 21:08:51 +08:00
|
|
|
<template>
|
|
|
|
<div :title="text" class="flex items-center">
|
2024-04-24 18:40:29 +08:00
|
|
|
<template v-if="text.length <= endCharacters">
|
|
|
|
<div class="shrink-0">
|
|
|
|
{{ text }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
2024-05-07 16:45:07 +08:00
|
|
|
<div class="truncate whitespace-pre">
|
2024-04-24 18:40:29 +08:00
|
|
|
{{ text.slice(0, endCharacters * -1) }}
|
|
|
|
</div>
|
2024-05-07 16:45:07 +08:00
|
|
|
<div class="shrink-0 whitespace-pre">
|
2024-04-24 18:40:29 +08:00
|
|
|
{{ text.slice(text.length - endCharacters) }}
|
|
|
|
</div>
|
|
|
|
</template>
|
2024-02-23 21:08:51 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'StringWithEllipsis',
|
|
|
|
props: {
|
|
|
|
text: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
endCharacters: {
|
|
|
|
type: Number,
|
|
|
|
default: 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|