記錄一次踩坑
由於在其他網站複製了一段文字,填寫到自己網站中並且釋出,其中包含了特殊字元,傳到後臺,再進行請求的時候,造成了前端crash
常用的換行分隔符,前端顯示一個黑點,json無法解析
所以新增了一個換行分隔符轉義方法
replaceUnicode (str) {
let temStr = str.replace('\u2028', '\\u2028')
temStr = temStr.replace('\u2029', '\\u2029')
temStr = temStr.replace('\u00A0', '\\u00A0')
return temStr
}
複製程式碼
