layer.open({ type: 1, skin: 'layui-layer-demo', //样式类名 closeBtn: 1, //不显示关闭按钮 anim: 2, shadeClose: true, //开启遮罩关闭 content: '<pre style="padding: 10px;">' + JSON.stringify(jsonstr, null, 5) + '</pre>', area: ['600px', '400px'] });解决方法:JSON.stringify()方法:就json对象转成json字符串,5:表示有5个空格缩进最多10个,但是发现打印的所有字符串还是连在一起,是因为html忽略了空格或者tab,使用<pre></pre>标签就好了。
json字符串格式化展示
猜你喜欢
转载自blog.csdn.net/qq_35321405/article/details/79789820
今日推荐
周排行