Just sent a blog, then found that csdn in the publishing user's article seems not to handle the input line and space, not very concerned about, because this time I worked hard to indent the code actually shows a mess, a bit unacceptable, in view of the recent need to meet this problem, so say this question, Given that development is under Windows, Linux and Apple are free to test again because different operating systems differ in their presentation.
In fact, this process is very simple, with a code can be solved, "your string". Replace (/\n/g, "<br/>"). Replace (/\s/g, " "), line wrap is usually \r,\n or \ r \ n , just different systems are not the same, we are interested to try. The principle is that textarea will insert the user button into the string, but in the browser, the <br/>,  that represents the line break and the space, so we need to turn to the browser character before rendering.
Incidentally, you can implement a simple textarea by H5 's property contenteditalble, but this is the input line and the space will be converted into a browser corresponding format, again show when we do not need to turn, but this property to implement the text box will have a lot of thorny problems, Interested to have a look.