json转字符串,并去掉大括号 const jsonStr = JSON.stringify(str).replace(/{|}/g, ‘’);字符串逗号换行 const reg = /,/g; const showStr = jsonStr.replace(reg,’\r\n’);对div添加css属性,确保\n起作用 “white-space”:“pre”