是否有一个标准的 javascript 函数可以将字符串拆分为两行相同(或几乎相同的行)而不破坏单词。
我真正想要的是:
- 如果文本包含少于 50 个符号(包括空格),则保持文本不变,
- 否则,将其拆分为长度相同(几乎相同)的两条线。
这需要以良好的方式显示文本,看起来很好。
例子:
Today is Monday.
Today is Monday, tomorrow is Tuesday. //less than 50 symbols.
Today is Monday, tomorrow is
Tuesday, after tomorrow is Wednesday. //splitted into two lines, Tuesday is on the second line.