I used ExpressJS to pass a string variable containing "\n" in the form of res.render('index', string)
, and in ejs output it in the form of <%= string %>
.
// string : abc\nabc\n
However, the string variable is printed in HTML, but the error text is printed on the page with "TypeError: Cannot create property '_locals' on string".
How can I output a string variable I have normally in ejs?
Since you need a new line escape character '\' as shown below:
string : abc\\nabc\\n
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.