简体   繁体   English

阅读更多 + React 中的省略号 (...) for dangerouslySetInnerHTML

[英]Read more + ellipsis (...) in React for dangerouslySetInnerHTML

Is there a good way to limit the # of lines of html grabbed with dangerouslySetInnerHTML and generate a '... Read More' expander for it for a React app?有没有一种很好的方法来限制使用 dangerouslySetInnerHTML 获取的 html 的行数并为 React 应用程序生成“...阅读更多”扩展器?

I've tried using react-lines-ellipsis but unfortunately the 'text' property doesn't work with dangerouslySetInnerHTML我试过使用 react-lines-ellipsis 但不幸的是 'text' 属性不适用于 dangerouslySetInnerHTML

try this, hope this will help试试这个,希望这会有所帮助

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

 p{
           max-width: 250px;
            display: -webkit-box;
            -webkit-line-clamp: 4;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM