index.js
733 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
// }
const lineEllipsis = (value,columnWidth,line = 1) => {
if (!value) return ''
// 假设一行的宽是字的个数10 160px的宽度 一个汉字16px
// 单元格左右的宽为16
const strleng = Math.ceil((columnWidth-36)/16) * line - 2
if (value.length > strleng) {
return value.substring(0, strleng) + '...'
}
}
export default {
lineEllipsis
}