index.js
330 Bytes
const lineEllipsis = (value,columnWidth,line = 1) => {
if (!value) return ''
// 假设一行的宽是字的个数10 160px的宽度 一个汉字16px
const strleng = Math.ceil(columnWidth/16) * line - 2
if (value.length > strleng) {
return value.substring(0, strleng) + '...'
}
}
export default {
lineEllipsis
}