• 2024-04-19
宇哥博客 前端开发 后台传过来的字符串包含换行符,JS中提示unterminated string错误

后台传过来的字符串包含换行符,JS中提示unterminated string错误

解决办法:

<!--在页面中加上这个,JS中使用-->
 <body>
<div style="display: none;">
    <pre id="pre_str">${content}</pre>
</div>
 
<script type="text/javascript">
    var content = $("#pre_str").html();//后台传过来的字符串
    console.log('content',content);
</script>
</body>
本文来自网络,不代表本站立场,转载请注明出处。http://www.ygbks.com/1040.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

返回顶部