【发布时间】:2020-09-25 12:24:04
【问题描述】:
我想显示一个包含 250 个字符的文本。
p #{description} // display all the description
我如何在哈巴狗中做到这一点?
我尝试使用 substr 或 length 但它不起作用。
感谢您的帮助
【问题讨论】:
我想显示一个包含 250 个字符的文本。
p #{description} // display all the description
我如何在哈巴狗中做到这一点?
我尝试使用 substr 或 length 但它不起作用。
感谢您的帮助
【问题讨论】:
substr() 等 JavaScript 方法可以在 Pug 模板中轻松使用。你提到尝试substr() 但没有成功。你的尝试是这样的吗?
p #{description.substr(0,250)}
这应该使用description 字符串的前250 个字符创建一个<p>,前提是它存在并且是一个字符串。
【讨论】: