11<script >
22 import Tooltip from ' ant-design-vue/es/tooltip'
33 import { cutStrByFullLength , getStrFullLength } from ' @/components/_util/StringUtil'
4- /*
5- const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined;
4+ /*
5+ const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined;
66
7- const TooltipOverlayStyle = {
8- overflowWrap: 'break-word',
9- wordWrap: 'break-word',
10- };
11- */
7+ const TooltipOverlayStyle = {
8+ overflowWrap: 'break-word',
9+ wordWrap: 'break-word',
10+ };
11+ */
1212
1313 export default {
1414 name: ' Ellipsis' ,
3737 }
3838 },
3939 methods: {
40- getStrDom (str ) {
40+ getStrDom (str , fullLength ) {
4141 return (
42- < span> { cutStrByFullLength (str, this .length ) + ' ...' }< / span>
42+ < span> { cutStrByFullLength (str, this .length ) + (fullLength > this . length ? ' ...' : ' ' ) }< / span>
4343 )
4444 },
45- getTooltip ( fullStr ) {
45+ getTooltip (fullStr , fullLength ) {
4646 return (
4747 < Tooltip>
4848 < template slot= " title" > { fullStr }< / template>
49- { this .getStrDom (fullStr) }
49+ { this .getStrDom (fullStr, fullLength ) }
5050 < / Tooltip>
5151 )
5252 }
5353 },
5454 render () {
5555 const { tooltip , length } = this .$props
5656 const str = this .$slots .default .map (vNode => vNode .text ).join (' ' )
57- const strDom = tooltip && getStrFullLength (str) > length ? this .getTooltip (str) : this .getStrDom (str)
57+ const fullLength = getStrFullLength (str)
58+ const strDom = tooltip && fullLength > length ? this .getTooltip (str, fullLength) : this .getStrDom (str, fullLength)
5859 return (
5960 strDom
6061 )
6162 }
6263 }
63- </script >
64+ </script >
0 commit comments