Split string in JavaScript and detect line break

前端 未结 7 1189
情书的邮戳
情书的邮戳 2020-12-24 04:55

I have a small function I found that takes a string from a textarea and then puts it into a canvas element and wraps the text when the line gets to

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 05:26

    You can use the split() function to break input on the basis of line break.

    yourString.split("\n")
    

提交回复
热议问题