{"id":27741,"date":"2024-11-24T12:10:10","date_gmt":"2024-11-24T04:10:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27741\/"},"modified":"2024-11-24T12:10:10","modified_gmt":"2024-11-24T04:10:10","slug":"vue-%e9%a1%b9%e7%9b%ae%e8%bf%90%e8%a1%8c%e6%97%b6%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e6%b5%8f%e8%a7%88%e5%99%a8%e6%89%93%e5%bc%80%e7%9a%84%e7%bd%91%e5%9d%80%e4%b8%8d%e6%98%af-http-localhost8080","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27741\/","title":{"rendered":"Vue \u9879\u76ee\u8fd0\u884c\u65f6\uff0c\u4e3a\u4ec0\u4e48\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f http:\/\/localhost:8080 \u800c\u662f http:\/\/0.0.0.0:8080\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173131056487808.jpg\" class=\"aligncenter\" title=\"Vue \u9879\u76ee\u8fd0\u884c\u65f6\uff0c\u4e3a\u4ec0\u4e48\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f http:\/\/localhost:8080 \u800c\u662f http:\/\/0.0.0.0:8080\uff1f\u63d2\u56fe\" alt=\"Vue \u9879\u76ee\u8fd0\u884c\u65f6\uff0c\u4e3a\u4ec0\u4e48\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f http:\/\/localhost:8080 \u800c\u662f http:\/\/0.0.0.0:8080\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u9879\u76ee\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\u65f6\u51fa\u73b0\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 vue \u65f6\uff0c\u5e0c\u671b\u9879\u76ee\u80fd\u591f\u5728\u8fd0\u884c\u65f6\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u5374\u53d1\u73b0\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f\u9884\u671f\u7684 http:\/\/localhost:8080\uff0c\u800c\u662f http:\/\/0.0.0.0:8080\u3002\u4e0b\u9762\u5c06\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u95ee\u9898\u5206\u6790\uff1a<\/strong><\/p>\n<p>\u6839\u636e\u63d0\u4f9b\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u5728\u4f7f\u7528 vue cli \u521b\u5efa\u9879\u76ee\u65f6\u6ca1\u6709\u6307\u5b9a\u989d\u5916\u7684\u914d\u7f6e\u9009\u9879\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u9879\u76ee\u5c06\u542f\u52a8\u4e00\u4e2a\u672c\u5730\u670d\u52a1\u5668\uff0c\u5176\u4e3b\u673a\u5730\u5740\u4e3a 0.0.0.0\u3002\u8fd9\u4f1a\u5bfc\u81f4\u6d4f\u89c8\u5668\u6253\u5f00\u65f6\u663e\u793a\u4e0d\u671f\u671b\u7684\u7f51\u5740\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848 1\uff1a\u4fee\u6539 devserver.host<\/strong><\/p>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u7684 vue.config.js \u6587\u4ef6\u4e2d\uff0c\u4fee\u6539 devserver \u914d\u7f6e\u7684 host \u5c5e\u6027\u3002\u5c06 0.0.0.0 \u66ff\u6362\u4e3a localhost\u3002<\/p>\n<pre>\/\/ vue.config.js\nmodule.exports = {\n  devserver: {\n    host: 'localhost',\n    port: 8080,\n  },\n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848 2\uff1a\u4f7f\u7528 &#8211;host \u53c2\u6570<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 serve \u547d\u4ee4\u8fd0\u884c\u9879\u76ee\u65f6\uff0c\u53ef\u4ee5\u6dfb\u52a0 &#8211;host \u53c2\u6570\u6765\u6307\u5b9a\u4e3b\u673a\u5730\u5740\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>vue-cli-service serve --host localhost<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8865\u5145\uff1a<\/strong><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528 0.0.0.0 \u4f5c\u4e3a\u4e3b\u673a\u5730\u5740\u4ece\u672c\u8d28\u4e0a\u6765\u8bf4\u4e0e\u4f7f\u7528 localhost \u662f\u7b49\u4ef7\u7684\u3002\u5b83\u4eec\u90fd\u5c06\u4f7f\u6d4f\u89c8\u5668\u6253\u5f00\u672c\u5730\u670d\u52a1\u5668\u3002\u4f46\u662f\uff0c\u4e3a\u4e86\u660e\u786e\u8d77\u89c1\uff0c\u4fee\u6539 devserver.host \u6216\u4f7f\u7528 &#8211;host \u53c2\u6570\u6307\u5b9a localhost \u53ef\u4ee5\u786e\u4fdd\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u7f51\u5740\u4e0e\u9884\u671f\u4e00\u81f4\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue \u9879\u76ee\u8fd0\u884c\u65f6\uff0c\u6d4f\u89c8\u5668\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f http:\/\/localhost:8080 \u800c\u662f http:\/\/0.0.0.0:8080\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\u65f6\u51fa\u73b0\u95ee\u9898 \u5728\u4f7f\u7528 vue \u65f6\uff0c\u5e0c\u671b\u9879\u76ee\u80fd\u591f\u5728\u8fd0\u884c\u65f6\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u5374\u53d1\u73b0\u6253\u5f00\u7684\u7f51\u5740\u4e0d\u662f\u9884\u671f\u7684 http:\/\/localhost:8080\uff0c\u800c\u662f http:\/\/0.0.0.0:8080\u3002\u4e0b\u9762\u5c06\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\u3002 \u95ee\u9898\u5206\u6790\uff1a \u6839\u636e\u63d0\u4f9b\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u5728\u4f7f\u7528 vue cli \u521b\u5efa\u9879\u76ee\u65f6\u6ca1\u6709\u6307\u5b9a\u989d\u5916\u7684\u914d\u7f6e\u9009\u9879\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u9879\u76ee\u5c06\u542f\u52a8\u4e00\u4e2a\u672c\u5730\u670d\u52a1\u5668\uff0c\u5176\u4e3b\u673a\u5730\u5740\u4e3a 0.0.0.0\u3002\u8fd9\u4f1a\u5bfc\u81f4\u6d4f\u89c8\u5668\u6253\u5f00\u65f6\u663e\u793a\u4e0d\u671f\u671b\u7684\u7f51\u5740\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u89e3\u51b3\u65b9\u6848 1\uff1a\u4fee\u6539 devserver.host \u5728\u9879\u76ee\u6839\u76ee\u5f55\u7684 vue.config.js \u6587\u4ef6\u4e2d\uff0c\u4fee\u6539 devserver \u914d\u7f6e\u7684 host \u5c5e\u6027\u3002\u5c06 0.0.0.0 \u66ff\u6362\u4e3a localhost\u3002 \/\/ vue.config.js module.exports = { devserver: { host: &#8216;localhost&#8217;, port: 8080, }, }; \u767b\u5f55\u540e\u590d\u5236 \u89e3\u51b3\u65b9\u6848 2\uff1a\u4f7f\u7528 &#8211;host \u53c2\u6570 \u5728\u4f7f\u7528 serve \u547d\u4ee4\u8fd0\u884c\u9879\u76ee\u65f6\uff0c\u53ef\u4ee5\u6dfb\u52a0 &#8211;host \u53c2\u6570\u6765\u6307\u5b9a\u4e3b\u673a\u5730\u5740\u3002\u4f8b\u5982\uff1a vue-cli-service serve &#8211;host localhost \u767b\u5f55\u540e\u590d\u5236 \u8865\u5145\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27741","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27741"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27741\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}