mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 06:06:56 +08:00
33 lines
641 B
Vue
33 lines
641 B
Vue
<template>
|
|
<div :title="text" class="flex items-center">
|
|
<template v-if="text.length <= endCharacters">
|
|
<div class="shrink-0">
|
|
{{ text }}
|
|
</div>
|
|
</template>
|
|
<template v-else>
|
|
<div class="truncate whitespace-pre">
|
|
{{ text.slice(0, endCharacters * -1) }}
|
|
</div>
|
|
<div class="shrink-0 whitespace-pre">
|
|
{{ text.slice(text.length - endCharacters) }}
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'StringWithEllipsis',
|
|
props: {
|
|
text: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
endCharacters: {
|
|
type: Number,
|
|
default: 4
|
|
}
|
|
}
|
|
};
|
|
</script>
|