1 s = s.replace("\n\r", "<br> ");
2 s = s.replace("\r\n", "<br> ");//这才是正确的!
3 s= s.replace("\t", " ");
4 s =s.replace(" ", " "); ///这个按需要看自己是否要加, 我的不需要 也就没加
5
6 s=s.replace("\"", "\\"+"\"");//如果原文含有双引号,这一句最关键!!!!!!
后台数据库中存储的editor编辑器编辑的文字, 前端需要再js中 使用 作为提示信息, 如果不加控制,前端js解析会报错误,故此 几句办法如上,
保存时候过滤掉不需要
的信息
Error: unterminated string
literal。通常原因是输出字符str中包含换行符导致的。
时间: 2024-08-10 23:30:37