欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

html页面格式化输出js对象

发布时间:2022/11/16 HTML 11 老码农
如意编程网 收集整理的这篇文章主要介绍了 html页面格式化输出js对象 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

将js中的对象格式化,并打印在html中

function writeHtml(name,obj) {
    var objStr = JSON.stringify(obj, null, 4);
    var html = objStr.replace(/\n/g, '<br>').replace(/\s/g, '&nbsp');
    document.write(name+':'+html);
}

 

html页面格式化输出js对象

div[class="ant-popover-inner-content"] { padding-top: 10px !important; padding-right: 0 !important; padding-bottom: 10px !important; padding-left: 0 !important; }

 

总结

以上是如意编程网为你收集整理的html页面格式化输出js对象的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。