{"id":6112,"date":"2023-01-07T10:52:23","date_gmt":"2023-01-07T02:52:23","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6112"},"modified":"2023-01-07T10:52:23","modified_gmt":"2023-01-07T02:52:23","slug":"%e4%ba%86%e8%a7%a3node-js%e4%b8%ad%e7%9a%84%e9%8c%af%e8%aa%a4%e8%99%95%e7%90%86","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/node-js\/%e4%ba%86%e8%a7%a3node-js%e4%b8%ad%e7%9a%84%e9%8c%af%e8%aa%a4%e8%99%95%e7%90%86\/","title":{"rendered":"\u4e86\u89e3Node.js\u4e2d\u7684\u932f\u8aa4\u8655\u7406"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Node.js, \u932f\u8aa4\u8655\u7406, \u9762\u8a66\u984c\u76ee\"><\/p>\n<h1>Node.js \u932f\u8aa4\u8655\u7406\u9762\u8a66\u984c\u76ee\u89e3\u6790<\/h1>\n<p>Node.js \u662f\u4e00\u500b\u5ee3\u53d7\u6b61\u8fce\u7684JavaScript \u57f7\u884c\u74b0\u5883\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5efa\u7acb\u9ad8\u6548\u7387\u7684\u61c9\u7528\u7a0b\u5f0f\u3002\u5728\u958b\u767c Node.js \u61c9\u7528\u7a0b\u5f0f\u6642\uff0c\u932f\u8aa4\u8655\u7406\u662f\u4e00\u500b\u91cd\u8981\u7684\u8b70\u984c\uff0c\u56e0\u6b64\uff0c\u8a31\u591a\u9762\u8a66\u5b98\u6703\u554f\u5230\u95dc\u65bc Node.js \u932f\u8aa4\u8655\u7406\u7684\u9762\u8a66\u984c\u76ee\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f Node.js \u932f\u8aa4\u8655\u7406\uff1f<\/h2>\n<p>Node.js \u932f\u8aa4\u8655\u7406\u662f\u6307\u5728 Node.js \u61c9\u7528\u7a0b\u5f0f\u4e2d\uff0c\u5c0d\u65bc\u767c\u751f\u7684\u932f\u8aa4\u9032\u884c\u8655\u7406\u7684\u904e\u7a0b\u3002\u7576\u7a0b\u5f0f\u767c\u751f\u932f\u8aa4\u6642\uff0cNode.js \u6703\u62cb\u51fa\u4e00\u500b\u932f\u8aa4\u7269\u4ef6\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528\u9019\u500b\u932f\u8aa4\u7269\u4ef6\u4f86\u6aa2\u67e5\u932f\u8aa4\u7684\u539f\u56e0\uff0c\u4e26\u6c7a\u5b9a\u5982\u4f55\u8655\u7406\u9019\u500b\u932f\u8aa4\u3002<\/p>\n<h2>Node.js \u932f\u8aa4\u8655\u7406\u7684\u57fa\u672c\u539f\u5247<\/h2>\n<p>Node.js \u932f\u8aa4\u8655\u7406\u7684\u57fa\u672c\u539f\u5247\u662f\uff1a<\/p>\n<ul>\n<li>\u6aa2\u67e5\u932f\u8aa4\uff1a\u5728\u7a0b\u5f0f\u4e2d\uff0c\u61c9\u8a72\u6aa2\u67e5\u53ef\u80fd\u767c\u751f\u7684\u932f\u8aa4\uff0c\u4e26\u63d0\u4f9b\u9069\u7576\u7684\u8655\u7406\u65b9\u5f0f\u3002<\/li>\n<li>\u6355\u7372\u932f\u8aa4\uff1a\u7576\u7a0b\u5f0f\u767c\u751f\u932f\u8aa4\u6642\uff0c\u61c9\u8a72\u6355\u7372\u932f\u8aa4\uff0c\u4e26\u63d0\u4f9b\u9069\u7576\u7684\u8655\u7406\u65b9\u5f0f\u3002<\/li>\n<li>\u8655\u7406\u932f\u8aa4\uff1a\u61c9\u8a72\u63d0\u4f9b\u9069\u7576\u7684\u8655\u7406\u65b9\u5f0f\uff0c\u4f86\u8655\u7406\u767c\u751f\u7684\u932f\u8aa4\u3002<\/li>\n<li>\u8a18\u9304\u932f\u8aa4\uff1a\u61c9\u8a72\u5c07\u932f\u8aa4\u8a18\u9304\u4e0b\u4f86\uff0c\u4ee5\u4fbf\u65e5\u5f8c\u67e5\u8a62\u3002<\/li>\n<\/ul>\n<h2>Node.js \u932f\u8aa4\u8655\u7406\u7684\u7a0b\u5f0f\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684 Node.js \u932f\u8aa4\u8655\u7406\u7684\u7a0b\u5f0f\u7bc4\u4f8b\uff1a<\/p>\n<pre class=\"brush: javascript\">\ntry {\n    \/\/ \u57f7\u884c\u7a0b\u5f0f\n} catch (err) {\n    \/\/ \u6355\u7372\u932f\u8aa4\n    console.error(err);\n    \/\/ \u8655\u7406\u932f\u8aa4\n    \/\/ ...\n}\n<\/pre>\n<p>\u5728\u9019\u500b\u7a0b\u5f0f\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 <code>try...catch<\/code> \u8a9e\u53e5\u4f86\u6355\u7372\u932f\u8aa4\uff0c\u4e26\u4f7f\u7528 <code>console.error()<\/code> \u65b9\u6cd5\u5c07\u932f\u8aa4\u8a0a\u606f\u8f38\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u7136\u5f8c\u518d\u6839\u64da\u932f\u8aa4\u60c5\u6cc1\u63d0\u4f9b\u9069\u7576\u7684\u8655\u7406\u65b9\u5f0f\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>Node.js \u932f\u8aa4\u8655\u7406\u662f\u6307\u5728 Node.js \u61c9\u7528\u7a0b\u5f0f\u4e2d\uff0c\u5c0d\u65bc\u767c\u751f\u7684\u932f\u8aa4\u9032\u884c\u8655\u7406\u7684\u904e\u7a0b\u3002Node.js \u932f\u8aa4\u8655\u7406\u7684\u57fa\u672c\u539f\u5247\u662f\uff1a\u6aa2\u67e5\u932f\u8aa4\u3001\u6355\u7372\u932f\u8aa4\u3001\u8655\u7406\u932f\u8aa4\u548c\u8a18\u9304\u932f\u8aa4\u3002\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528 <code>try...catch<\/code> \u8a9e\u53e5\u4f86\u6355\u7372\u932f\u8aa4\uff0c\u4e26\u4f7f\u7528 <code>console.error()<\/code> \u65b9\u6cd5\u5c07\u932f\u8aa4\u8a0a\u606f\u8f38\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u7136\u5f8c\u518d\u6839\u64da\u932f\u8aa4\u60c5\u6cc1\u63d0\u4f9b\u9069\u7576\u7684\u8655\u7406\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981(Description):Node.js\u662f\u4e00\u7a2e\u57fa\u65bcJavaScript\u7684\u958b\u6e90\u3001\u8de8\u5e73\u53f0\u7684\u8173\u672c\u8a9e\u8a00\uff0c\u5b83\u53ef\u4ee5\u7528\u65bc\u958b\u767c\u670d\u52d9\u5668\u7aef\u548c\u7db2\u7d61\u61c9\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39Node.js\u4e2d\u7684\u932f\u8aa4\u8655\u7406\uff0c\u8b93\u5b78\u751f\u66f4\u52a0\u4e86\u89e3Node.js\u7684\u932f\u8aa4\u8655\u7406\u6a5f\u5236\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[193,192],"tags":[191,190],"class_list":["post-6112","post","type-post","status-publish","format-standard","hentry","category-node","category-node-js","tag-node","tag-node-js"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1AA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=6112"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6112\/revisions"}],"predecessor-version":[{"id":6113,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6112\/revisions\/6113"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=6112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}