{"id":74182,"date":"2024-01-07T22:13:49","date_gmt":"2024-01-07T14:13:49","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=74182"},"modified":"2024-01-07T22:13:49","modified_gmt":"2024-01-07T14:13:49","slug":"ctsjhjyhqdkfxl","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/74182.html","title":{"rendered":"Console \u8c03\u8bd5\u4ea4\u6362\u673a\uff1a\u4f18\u5316\u524d\u7aef\u5f00\u53d1\u6548\u7387"},"content":{"rendered":"

  \u5728\u524d\u7aef\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0cconsole \u8c03\u8bd5\u4ea4\u6362\u673a\u662f\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u5de5\u5177\u3002\u672c\u6587\u5c06\u56f4\u7ed5console\u8c03\u8bd5\u4ea4\u6362\u673a\u5c55\u5f00\u8ba8\u8bba\uff0c\u63a2\u8ba8\u5176\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\u7684\u4f5c\u7528\u548c\u4f18\u5316\u6548\u679c\u3002<\/p>\n

1. \u4f7f\u7528 Console \u8c03\u8bd5\u4ea4\u6362\u673a\u63d0\u9ad8\u4ee3\u7801\u8c03\u8bd5\u6548\u7387<\/h2>\n

  1.1 Console \u8c03\u8bd5\u4ea4\u6362\u673a\u7b80\u4ecb<\/h3>\n

  Console \u8c03\u8bd5\u4ea4\u6362\u673a\u662f\u6307\u5229\u7528 console \u5bf9\u8c61\u7684\u65b9\u6cd5\u6765\u8fdb\u884c\u8c03\u8bd5\u548c\u65e5\u5fd7\u8f93\u51fa\u3002\u901a\u8fc7\u5728\u63a7\u5236\u53f0\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\uff08\u5982console.log\u3001console.error\u3001console.warn\u7b49\uff09\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u66f4\u9ad8\u6548\u5730\u5b9a\u4f4d\u4ee3\u7801\u95ee\u9898\uff0c\u76d1\u63a7\u7a0b\u5e8f\u6267\u884c\u60c5\u51b5\u3002<\/p>\n

  1.2 Console \u8c03\u8bd5\u4ea4\u6362\u673a\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\u7684\u5e94\u7528<\/h3>\n

  \u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0cconsole \u8c03\u8bd5\u4ea4\u6362\u673a\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u4ee3\u7801\u8c03\u8bd5\u3001\u6027\u80fd\u76d1\u63a7\u548c\u9519\u8bef\u5904\u7406\u7b49\u65b9\u9762\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528console.log\u8f93\u51fa\u53d8\u91cf\u503c\u3001\u8c03\u8bd5\u4fe1\u606f\uff0c\u901a\u8fc7console.error\u548cconsole.warn\u8f93\u51fa\u9519\u8bef\u548c\u8b66\u544a\u4fe1\u606f\uff0c\u8f85\u52a9\u5b9a\u4f4d\u5e76\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n

2. Console \u8c03\u8bd5\u4ea4\u6362\u673a\u7684\u6700\u4f73\u5b9e\u8df5\u4e0e\u4f7f\u7528\u6280\u5de7<\/h2>\n

  2.1 \u5229\u7528 Console \u65e5\u5fd7\u8fdb\u884c\u7a0b\u5e8f\u72b6\u6001\u8ffd\u8e2a<\/h3>\n

  \u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u5408\u7406\u5730\u5229\u7528console.log\u548cconsole.group\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8fdb\u884c\u7a0b\u5e8f\u72b6\u6001\u8ffd\u8e2a\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u6e05\u6670\u5730\u4e86\u89e3\u4ee3\u7801\u6267\u884c\u6d41\u7a0b\u548c\u53d8\u91cf\u72b6\u6001\u3002<\/p>\n

  2.2 \u4f7f\u7528 Console \u5bf9\u8c61\u8fdb\u884c\u6027\u80fd\u76d1\u63a7<\/h3>\n

  \u5728\u7528\u6237\u4f53\u9a8c\u4f18\u5316\u548c\u6027\u80fd\u8c03\u4f18\u8fc7\u7a0b\u4e2d\uff0cconsole \u65f6\u95f4\u8f74\u3001console.profile\u548cconsole.count\u7b49\u65b9\u6cd5\u80fd\u591f\u63d0\u4f9b\u7a0b\u5e8f\u6267\u884c\u65f6\u95f4\u3001\u5185\u5b58\u5360\u7528\u548c\u51fd\u6570\u8c03\u7528\u6b21\u6570\u7b49\u91cd\u8981\u4fe1\u606f\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u4f18\u5316\u7a0b\u5e8f\u6027\u80fd\u3002<\/p>\n

  2.3 \u63a7\u5236\u53f0\u4e2d\u7684\u8c03\u8bd5\u6280\u5de7<\/h3>\n

  Console \u8c03\u8bd5\u4ea4\u6362\u673a\u8fd8\u652f\u6301\u66f4\u4e30\u5bcc\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u5982\u65ad\u70b9\u8c03\u8bd5\u3001\u6761\u4ef6\u65ad\u70b9\u3001\u76d1\u89c6\u8868\u8fbe\u5f0f\u7b49\uff0c\u8fd9\u4e9b\u6280\u5de7\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u9ad8\u6548\u5730\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n

3. \u603b\u7ed3<\/h2>\n

  3.1 Console \u8c03\u8bd5\u4ea4\u6362\u673a\u7684\u91cd\u8981\u6027<\/h3>\n

  Console \u8c03\u8bd5\u4ea4\u6362\u673a\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0c\u5b83\u4e0d\u4ec5\u662f\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u7684\u5229\u5668\uff0c\u66f4\u662f\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4f18\u5316\u7a0b\u5e8f\u6027\u80fd\u7684\u5173\u952e\u5de5\u5177\u3002<\/p>\n

  3.2 \u63a8\u8350\u9605\u8bfb<\/h3>\n

  \u5982\u679c\u60a8\u5bf9\u524d\u7aef\u8c03\u8bd5\u4e0e\u4f18\u5316\u6280\u672f\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u9605\u8bfb\u66f4\u591a\u5173\u4e8e JavaScript \u8c03\u8bd5\u548c\u6027\u80fd\u4f18\u5316\u7684\u76f8\u5173\u6587\u7ae0\uff0c\u4e0d\u65ad\u63d0\u5347\u81ea\u5df1\u7684\u6280\u672f\u6c34\u5e73\u3002<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u524d\u7aef\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0cconsole\u8c03\u8bd5\u4ea4\u6362\u673a\u662f\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u5de5\u5177\u3002\u672c\u6587\u5c06\u56f4\u7ed5console\u8c03\u8bd5\u4ea4\u6362\u673a\u5c55\u5f00\u8ba8\u8bba\uff0c\u63a2\u8ba8\u5176\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\u7684\u4f5c\u7528\u548c\u4f18\u5316\u6548\u679c\u30021.\u4f7f\u7528Cons<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[52],"class_list":["post-74182","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-wxtx"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/74182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=74182"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/74182\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=74182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=74182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=74182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}