1
1
<script >
2
2
import Tooltip from ' ant-design-vue/es/tooltip'
3
3
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;
6
6
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
+ */
12
12
13
13
export default {
14
14
name: ' Ellipsis' ,
37
37
}
38
38
},
39
39
methods: {
40
- getStrDom (str ) {
40
+ getStrDom (str , fullLength ) {
41
41
return (
42
- < span> { cutStrByFullLength (str, this .length ) + ' ...' }< / span>
42
+ < span> { cutStrByFullLength (str, this .length ) + (fullLength > this . length ? ' ...' : ' ' ) }< / span>
43
43
)
44
44
},
45
- getTooltip ( fullStr ) {
45
+ getTooltip (fullStr , fullLength ) {
46
46
return (
47
47
< Tooltip>
48
48
< template slot= " title" > { fullStr }< / template>
49
- { this .getStrDom (fullStr) }
49
+ { this .getStrDom (fullStr, fullLength ) }
50
50
< / Tooltip>
51
51
)
52
52
}
53
53
},
54
54
render () {
55
55
const { tooltip , length } = this .$props
56
56
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)
58
59
return (
59
60
strDom
60
61
)
61
62
}
62
63
}
63
- </script >
64
+ </script >
0 commit comments