react中单行文本溢出省略号

import styled from 'styled-components'

const ellipsis = (WrappedComp) => {
return styled(WrappedComp) overflow : hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: ${({lc}) => lc || 1 }; -webkit-box-orient: vertical;
}

export default ellipsis

使用方法:传参lc 表示第几行溢出隐藏

使用示例:
要设置的元素的样式文件:const SubTitle = ellipsis(
styled.p ``
)
要设置的元素的jsx文件:
{value.all_click}浏览 {value.favorites}收藏

原文地址:https://www.cnblogs.com/94-Lucky/p/13877541.html