微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么 chrome 控制台不将 "\n" 显示为字符串,而将 console.log 输出显示为正常的换行符?

如何解决为什么 chrome 控制台不将 "\n" 显示为字符串,而将 console.log 输出显示为正常的换行符?

Chrome 版本:90.0.4430.212

输入 "1\n2" 然后输入 "enter" 显示 "\n" 字符串

输入“console.log('1\n2')”然后输入“enter”显示正常

enter image description here

解决方法

控制台将 \n 读取为新行,并以换行符的方式输出。

如果你想在控制台中看到 \n 使用 JSON.stringify()。

示例:

parameters.ReferencedAssemblies.AddRange(references);
CompilerResults compiledCode = compiler.CompileAssemblyFromSource(parameters,code);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。