{"id":28043,"date":"2024-11-24T14:55:21","date_gmt":"2024-11-24T06:55:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28043\/"},"modified":"2024-11-24T14:55:21","modified_gmt":"2024-11-24T06:55:21","slug":"vue-%e9%a1%b9%e7%9b%ae%e5%90%af%e5%8a%a8%e6%97%b6%e5%a6%82%e4%bd%95%e8%87%aa%e5%8a%a8%e6%89%93%e5%bc%80%e5%b9%b6%e8%b7%b3%e8%bd%ac%e5%88%b0%e6%8c%87%e5%ae%9a%e5%9c%b0%e5%9d%80%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28043\/","title":{"rendered":"Vue \u9879\u76ee\u542f\u52a8\u65f6\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173138503584655.jpg\" class=\"aligncenter\" title=\"Vue \u9879\u76ee\u542f\u52a8\u65f6\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\uff1f\u63d2\u56fe\" alt=\"Vue \u9879\u76ee\u542f\u52a8\u65f6\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u9879\u76ee\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\uff1f<\/strong><\/p>\n<p>\u5728\u4f60\u4f7f\u7528 vue create \u521b\u5efa\u9879\u76ee\u540e\uff0c\u4f60\u53ef\u80fd\u5e0c\u671b\u5728\u542f\u52a8\u9879\u76ee\u65f6\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u540c\u65f6\u8df3\u8f6c\u5230\u6307\u5b9a\u7684 url\uff0c\u4f8b\u5982 http:\/\/localhost:8080\/\u3002<\/p>\n<p><strong>\u4fee\u590d\u65b9\u6848\uff1a<\/strong><\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 &#8211;host \u53c2\u6570\u9879<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>vue serve --host localhost<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4f1a\u5f3a\u5236\u6d4f\u89c8\u5668\u6253\u5f00 http:\/\/localhost:8080\/\u3002<\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4fee\u6539 devserver.host<\/strong><\/p>\n<p>\u5728\u4f60\u7684 vue.config.js \u6587\u4ef6\u4e2d\u627e\u5230 devserver \u5bf9\u8c61\uff1a<\/p>\n<pre>module.exports = {\n  devServer: {\n    \/\/ ...\n    host: 'localhost' \/\/ \u8bbe\u7f6e\u4e3a '0.0.0.0' \u4e5f\u53ef\u4ee5\uff0c\u56e0\u4e3a\u4e24\u8005\u672c\u8d28\u4e0a\u662f\u4e00\u6837\u7684\u3002\n  }\n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4fee\u6539 devserver.host \u4e3a localhost\uff0c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u4f1a\u6253\u5f00 http:\/\/localhost:8080\/\u3002<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c0.0.0.0 \u672c\u8d28\u4e0a\u4e0e localhost \u76f8\u540c\uff0c\u56e0\u6b64\u4e0d\u5fc5\u975e\u8981\u4fee\u6539 devserver.host\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue \u9879\u76ee\u542f\u52a8\u65f6\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\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\u5982\u4f55\u81ea\u52a8\u6253\u5f00\u5e76\u8df3\u8f6c\u5230\u6307\u5b9a\u5730\u5740\uff1f \u5728\u4f60\u4f7f\u7528 vue create \u521b\u5efa\u9879\u76ee\u540e\uff0c\u4f60\u53ef\u80fd\u5e0c\u671b\u5728\u542f\u52a8\u9879\u76ee\u65f6\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u540c\u65f6\u8df3\u8f6c\u5230\u6307\u5b9a\u7684 url\uff0c\u4f8b\u5982 http:\/\/localhost:8080\/\u3002 \u4fee\u590d\u65b9\u6848\uff1a \u65b9\u6cd5 1\uff1a\u4f7f\u7528 &#8211;host \u53c2\u6570\u9879 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b vue serve &#8211;host localhost \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4f1a\u5f3a\u5236\u6d4f\u89c8\u5668\u6253\u5f00 http:\/\/localhost:8080\/\u3002 \u65b9\u6cd5 2\uff1a\u4fee\u6539 devserver.host \u5728\u4f60\u7684 vue.config.js \u6587\u4ef6\u4e2d\u627e\u5230 devserver \u5bf9\u8c61\uff1a module.exports = { devServer: { \/\/ &#8230; host: &#8216;localhost&#8217; \/\/ \u8bbe\u7f6e\u4e3a &#8216;0.0.0.0&#8217; \u4e5f\u53ef\u4ee5\uff0c\u56e0\u4e3a\u4e24\u8005\u672c\u8d28\u4e0a\u662f\u4e00\u6837\u7684\u3002 } }; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4fee\u6539 devserver.host \u4e3a localhost\uff0c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u4f1a\u6253\u5f00 http:\/\/localhost:8080\/\u3002 \u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c0.0.0.0 \u672c\u8d28\u4e0a\u4e0e localhost \u76f8\u540c\uff0c\u56e0\u6b64\u4e0d\u5fc5\u975e\u8981\u4fee\u6539 devserver.host\u3002 \u4ee5\u4e0a\u5c31\u662fVue [&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-28043","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28043","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=28043"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28043\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}