{"id":315,"date":"2021-10-21T18:06:59","date_gmt":"2021-10-21T10:06:59","guid":{"rendered":"http:\/\/gjweb.top\/?p=315"},"modified":"2021-10-21T18:06:59","modified_gmt":"2021-10-21T10:06:59","slug":"vue%e4%b8%ad%e8%87%aa%e5%8a%a8%e5%88%a4%e6%96%ad%e5%bc%80%e5%8f%91%e5%8f%8a%e7%94%9f%e4%ba%a7%e7%8e%af%e5%a2%83%e5%88%87%e6%8d%a2%e6%8e%a5%e5%8f%a3%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=315","title":{"rendered":"vue\u4e2d\u81ea\u52a8\u5224\u65ad\u5f00\u53d1\u53ca\u751f\u4ea7\u73af\u5883\u5207\u6362\u63a5\u53e3\u4ee3\u7406"},"content":{"rendered":"\n<p>\u5728 main.js \u4e2d\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u81ea\u52a8\u6784\u5efa\u5f00\u53d1\u53ca\u751f\u4ea7\u73af\u5883API\u8def\u5f84\r\nif(process.env.NODE_ENV === \"development\"){\n  \/\/\u5f00\u53d1\u73af\u5883\r\n  Vue.prototype.$xxx = '\/xxx';\r\n  Vue.prototype.$xxx2= '\/xxx2';\r\n}else{\n \/\/\u751f\u4ea7\u73af\u5883\r\n  Vue.prototype.$xxx = '';\r\n  Vue.prototype.$xxx2= '';\r\n}<\/code><\/pre>\n\n\n\n<p>vueCli 2\u4ee5\u4e0a\u5728 vue.config.js \u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module.exports = {\r\n  devServer: {\r\n    proxy: {\r\n      \"\/xxx\": {\r\n        target: \"http:\/\/www.baidu.com\",\r\n        changeOrigin: true,\r\n        ws: true,\r\n        pathRewrite: {\r\n          \"^\/xxx\": ''\r\n        }\r\n      }\r\n    }\n    .... \u6dfb\u52a0\u5176\u4ed6\u4ee3\u7406\n  }\r\n}<\/code><\/pre>\n\n\n\n<p>vuecli2 \u4ee5\u4e0b\u914d\u7f6e\u4ee3\u7406\u5728 config\/index.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dev:{\n  proxyTable:{\n    '\/xxx': {\r\n        target: 'http:\/\/www.baidu.com',\r\n        changeOrigin: true,\r\n        secure: false,\r\n        pathRewrite: { \r\n          '^\/xxx': '' \r\n        }\r\n    },\n    .... \u6dfb\u52a0\u5176\u4ed6\u4ee3\u7406\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 main.js \u4e2d\u914d\u7f6e vueCli 2\u4ee5\u4e0a\u5728 vue.config.js \u4e2d vuecli2 \u4ee5\u4e0b\u914d\u7f6e\u4ee3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}