{"id":343,"date":"2023-12-13T11:07:50","date_gmt":"2023-12-13T03:07:50","guid":{"rendered":"http:\/\/ericw.top\/?p=343"},"modified":"2023-12-13T11:07:50","modified_gmt":"2023-12-13T03:07:50","slug":"%e5%8c%85%e7%9a%84%e6%a6%82%e5%bf%b5","status":"publish","type":"post","link":"http:\/\/ericw.top\/?p=343","title":{"rendered":"\u5305\u7684\u6982\u5ff5"},"content":{"rendered":"<h1 id=\"toc-0\">\u5305\u7684\u6982\u5ff5<\/h1>\n<p><strong>\u5305\uff1a\u5c06\u6a21\u5757\uff0c\u4ee3\u7801\uff0c\u5176\u4ed6\u8d44\u6599\u805a\u5408\u6210\u4e00\u4e2a\u6587\u4ef6\u5939<\/strong><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1702436149333-300x232.png\" alt=\"\" \/><\/p>\n<p><strong>\u5305\u5206\u7c7b\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u9879\u76ee\u5305\uff1a<\/strong>\u4e3b\u8981\u7528\u4e8e\u7f16\u5199\u9879\u76ee\u548c\u4e1a\u52a1\u903b\u8f91<\/li>\n<li><strong>\u8f6f\u4ef6\u5305\uff1a<\/strong>\u5c01\u88c5\u5de5\u5177\u548c\u65b9\u6cd5\u8fdb\u884c\u4f7f\u7528<\/li>\n<\/ul>\n<p><strong>\u8981\u6c42\uff1a<\/strong>\u5728\u6839\u76ee\u5f55\uff0c\u5fc5\u987b\u6709package.json\u6587\u4ef6\uff08\u8bb0\u5f55\u5305\u7684\u6e05\u5355\uff09<\/p>\n<p>package.json\u6587\u4ef6\u5e38\u7528\u914d\u7f6e\u9879\uff1a<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-json\">{\n    &quot;name&quot;:&quot;cz_utils&quot;,\n    &quot;version&quot;:&quot;1.0.0&quot;,\n    &quot;description&quot;:&quot;\u4e00\u4e2a\u6570\u7ec4\u548c\u5b57\u7b26\u4e32\u5e38\u7528\u5de5\u5177\u65b9\u6cd5\u7684\u5305&quot;,\n    &quot;main&quot;:&quot;index.js&quot;,\n    &quot;author&quot;:&quot;itheima&quot;,\n    &quot;license&quot;:&quot;MIT&quot;\n}<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/ericw.top\/wp-content\/uploads\/2023\/12\/1702436465437-300x85.png\" alt=\"\" \/><\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u5bfc\u5165\u8f6f\u4ef6\u5305\u65f6\uff0c\u5f15\u5165\u7684\u9ed8\u8ba4\u662findex.js\u6a21\u5757\u6587\u4ef6\/main\u5c5e\u6027\u6307\u5b9a\u7684\u6a21\u5757\u6587\u4ef6<\/p>\n<p><strong>\u9700\u6c42\uff1a<\/strong>\u5c01\u88c5\u6570\u7ec4\u6c42\u548c\u51fd\u6570\u7684\u6a21\u5757\uff0c\u5224\u65ad\u7528\u6237\u540d\u548c\u5bc6\u7801\u957f\u5ea6\u51fd\u6570\u7684\u6a21\u5757\uff0c\u5f62\u6210\u6210\u4e00\u4e2a\u8f6f\u4ef6\u5305<\/p>\n<ol>\n<li>\u5728index.js\u51fa\u53e3\u6587\u4ef6\u4ee3\u7801\u7f16\u5199\uff1a<\/li>\n<\/ol>\n<pre><code class=\"prettyprint\"  class=\"language-js\">\/**\n * \u672c\u6587\u4ef6\u662f\uff0cutils \u5de5\u5177\u5305\u7684\u552f\u4e00\u51fa\u53e3\n * \u4f5c\u7528\uff1a\u628a\u6240\u6709\u5de5\u5177\u6a21\u5757\u65b9\u6cd5\u96c6\u4e2d\u8d77\u6765\uff0c\u7edf\u4e00\u5411\u5916\u66b4\u9732\n *\/\nconst { getArraySum } = require(&#039;.\/lib\/arr.js&#039;)\nconst { checkUser, checkPwd } = require(&#039;.\/lib\/str.js&#039;)\n\n\/\/ \u7edf\u4e00\u5bfc\u51fa\u6240\u6709\u51fd\u6570\nmodule.exports = {\n  getArraySum,\n  checkUser,\n  checkPwd\n}<\/code><\/pre>\n<ol start=\"2\">\n<li>\u5728\u6211\u4eec\u9700\u8981\u4f7f\u7528\u7684\u5730\u65b9\u5bfc\u5165utils\u8f6f\u4ef6\u5305<\/li>\n<\/ol>\n<pre><code class=\"prettyprint\"  class=\"language-js\">\/**\n * \u76ee\u6807\uff1a\u5bfc\u5165 utils \u8f6f\u4ef6\u5305\uff0c\u4f7f\u7528\u91cc\u9762\u5c01\u88c5\u7684\u5de5\u5177\u51fd\u6570\n *\/\nconst obj = require(&#039;.\/utils&#039;)\nconsole.log(obj)\nconst result = obj.getArraySum([10, 20, 30])\nconsole.log(result)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5305\u7684\u6982\u5ff5 \u5305\uff1a\u5c06\u6a21\u5757\uff0c\u4ee3\u7801\uff0c\u5176\u4ed6\u8d44\u6599\u805a\u5408\u6210\u4e00\u4e2a\u6587\u4ef6\u5939 \u5305\u5206\u7c7b\uff1a \u9879\u76ee\u5305\uff1a\u4e3b\u8981\u7528\u4e8e\u7f16\u5199\u9879\u76ee\u548c\u4e1a\u52a1\u903b\u8f91 \u8f6f\u4ef6\u5305\uff1a\u5c01 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,5],"tags":[],"_links":{"self":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/343"}],"collection":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":1,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":346,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/346"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/media\/344"}],"wp:attachment":[{"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}