{"id":488,"date":"2023-12-15T12:04:31","date_gmt":"2023-12-15T04:04:31","guid":{"rendered":"http:\/\/ericw.top\/?p=488"},"modified":"2023-12-15T12:04:31","modified_gmt":"2023-12-15T04:04:31","slug":"%e5%a4%9a%e9%a1%b5%e9%9d%a2%e6%89%93%e5%8c%85","status":"publish","type":"post","link":"http:\/\/ericw.top\/?p=488","title":{"rendered":"\u591a\u9875\u9762\u6253\u5305"},"content":{"rendered":"<h1 id=\"toc-0\">\u591a\u9875\u9762\u6253\u5305<\/h1>\n<p><strong>\u5355\u9875\u9762\uff1a<\/strong>\u5355\u4e2a html \u6587\u4ef6\uff0c\u5207\u6362 DOM \u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u4e1a\u52a1\u903b\u8f91\u5c55\u793a<br \/>\n<strong>\u591a\u9875\u9762\uff1a<\/strong>\u591a\u4e2a html \u6587\u4ef6\uff0c\u5207\u6362\u9875\u9762\u5b9e\u73b0\u4e0d\u540c\u4e1a\u52a1\u903b\u8f91\u5c55\u793a<br \/>\n<strong>\u9700\u6c42\uff1a<\/strong>\u628a\u9ed1\u9a6c\u5934\u6761-\u6570\u636e\u7ba1\u7406\u5e73\u53f0-\u5185\u5bb9\u9875\u9762\u4e00\u8d77\u5f15\u5165\u6253\u5305\u4f7f\u7528<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><br \/>\n1\u3001\u51c6\u5907<strong>\u6e90\u7801\uff08html\uff0ccss\uff0cjs\uff09<\/strong>\u653e\u5165\u76f8\u5e94\u4f4d\u7f6e\uff0c\u5e76\u6539\u7528\u6a21\u5757\u5316\u8bed\u6cd5\u5bfc\u51fa<br \/>\n2\u3001\u4e0b\u8f7d <code class=\"prettyprint\" >form-serialize<\/code> \u5305\u5e76\u5bfc\u5165\u5230\u6838\u5fc3\u4ee3\u7801\u4e2d\u4f7f\u7528<br \/>\n3\u3001\u914d\u7f6e <code class=\"prettyprint\" >webpack.config.js<\/code> \u591a\u5165\u53e3\u548c\u591a\u9875\u9762\u7684\u8bbe\u7f6e<br \/>\n4\u3001\u91cd\u65b0\u6253\u5305\u89c2\u5bdf\u6548\u679c<\/p>\n<pre><code class=\"prettyprint\"  class=\"language-js\">const config = {\n  entry: {\n    &#039;login&#039;: path.resolve(__dirname, &#039;src\/login\/index.js&#039;),\n    &#039;content&#039;: path.resolve(__dirname, &#039;src\/content\/index.js&#039;),\n    &#039;publish&#039;: path.resolve(__dirname, &#039;src\/publish\/index.js&#039;)\n  },\n  \/\/ \u51fa\u53e3\n  output: {\n    path: path.resolve(__dirname, &#039;dist&#039;),\n    filename: &#039;.\/[name]\/index.js&#039;,\n    clean: true \/\/ \u751f\u6210\u6253\u5305\u540e\u5185\u5bb9\u4e4b\u524d\uff0c\u6e05\u7a7a\u8f93\u51fa\u76ee\u5f55\n  }\nplugins: [\n    new HtmlWebpackPlugin({\n      template: path.resolve(__dirname, &#039;public\/login.html&#039;), \/\/ \u6a21\u677f\u6587\u4ef6\n      filename: path.resolve(__dirname, &#039;dist\/login\/index.html&#039;), \/\/ \u8f93\u51fa\u6587\u4ef6\n      useCdn: process.env.NODE_ENV === &#039;production&#039;, \/\/ \u751f\u4ea7\u6a21\u5f0f\u4e0b\u4f7f\u7528 cdn \u5f15\u5165\u7684\u5730\u5740\n      chunks: [&#039;login&#039;] \/\/ \u5f15\u5165\u54ea\u4e9b\u6253\u5305\u540e\u7684\u6a21\u5757\uff08\u548c entry \u7684 key \u4e00\u81f4\uff09\n    }),\n    new HtmlWebpackPlugin({\n      template: path.resolve(__dirname, &#039;public\/content.html&#039;), \/\/ \u6a21\u677f\u6587\u4ef6\n      filename: path.resolve(__dirname, &#039;dist\/content\/index.html&#039;), \/\/ \u8f93\u51fa\u6587\u4ef6\n      useCdn: process.env.NODE_ENV === &#039;production&#039;, \/\/ \u751f\u4ea7\u6a21\u5f0f\u4e0b\u4f7f\u7528 cdn \u5f15\u5165\u7684\u5730\u5740\n      chunks: [&#039;content&#039;]\n    }),\n    new HtmlWebpackPlugin({\n      template: path.resolve(__dirname, &#039;public\/publish.html&#039;), \/\/ \u6a21\u677f\u6587\u4ef6\n      filename: path.resolve(__dirname, &#039;dist\/publish\/index.html&#039;), \/\/ \u8f93\u51fa\u6587\u4ef6\n      useCdn: process.env.NODE_ENV === &#039;production&#039;, \/\/ \u751f\u4ea7\u6a21\u5f0f\u4e0b\u4f7f\u7528 cdn \u5f15\u5165\u7684\u5730\u5740\n      chunks: [&#039;publish&#039;]\n    })\n  ]\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u591a\u9875\u9762\u6253\u5305 \u5355\u9875\u9762\uff1a\u5355\u4e2a html \u6587\u4ef6\uff0c\u5207\u6362 DOM \u7684\u65b9\u5f0f\u5b9e\u73b0\u4e0d\u540c\u4e1a\u52a1\u903b\u8f91\u5c55\u793a \u591a\u9875\u9762\uff1a\u591a\u4e2a html \u6587 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":489,"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\/488"}],"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=488"}],"version-history":[{"count":1,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/488\/revisions"}],"predecessor-version":[{"id":490,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/posts\/488\/revisions\/490"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=\/wp\/v2\/media\/489"}],"wp:attachment":[{"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=488"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ericw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}