javascript - 如何从 quill delta 对象制作描述文本
问题描述
我目前正在制作一个有博客的网站(我正在使用 quill 更准确地react-quilljs),我现在想在博客卡中添加简短描述
const jsonText = JSON.parse(article.body);
let text = jsonText.ops[0].insert;
这是我从 delta 对象获得的示例数据
ops:[
insert:"text ...."
]
我希望有可能进行例如不删减单词并显示少于 50 个单词的描述。如果它可以只呈现没有任何标题属性的文本单词。是否有任何选择来实现它,或者我必须保留我现在使用的东西。
解决方案
你可以试试 text-overflow text-overflow我加了一个例子。
div.b {
white-space: nowrap;
width: 250px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
}
<div class="b">
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</div>
推荐阅读
- javascript - Yii2 将参数从按钮发送到 modal-ajax
- c++ - 这个 power() 函数的复杂度是多少?
- django - 如何为网络和移动设备使用相同的 django 后端?
- node.js - 无法解析模块“perf_hooks”
- telegram - 电报原生支持微软的自适应卡吗?
- c++ - 概念的重载/专业化
- java - 修正字符串分析的算法
- android - 使用 AppCompatButton 崩溃的 MaterialTimePicker 无法转换为 MaterialButton
- python - 使用组合框选择一个字符串并存储在 Tkinter 窗口关闭后要使用的变量中
- scala - 使用 Future 和 Async 处理多个文件 IO 请求而不阻塞