{"id":2840,"date":"2018-12-28T14:42:48","date_gmt":"2018-12-28T06:42:48","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=2840"},"modified":"2018-12-28T14:42:48","modified_gmt":"2018-12-28T06:42:48","slug":"vue%e9%a1%b9%e7%9b%ae%e6%89%93%e5%8c%85%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98%e6%95%b4%e7%90%86","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=2840","title":{"rendered":"Vue\u9879\u76ee\u6253\u5305\u5e38\u89c1\u95ee\u9898\u6574\u7406"},"content":{"rendered":"<p>Vue \u9879\u76ee\u5728\u5f00\u53d1\u65f6\u8fd0\u884c\u6b63\u5e38\uff0c\u6253\u5305\u53d1\u5e03\u540e\u5374\u51fa\u73b0\u5404\u79cd\u62a5\u9519\uff0c\u8fd9\u91cc\u6574\u7406\u4e00\u4e0b\u9047\u5230\u7684\u95ee\u9898\uff0c\u4ee5\u5907\u5fd8\u3002<\/p>\n<p>1\u3001js \u8def\u5f84\u95ee\u9898<\/p>\n<p>\u811a\u624b\u67b6\u9ed8\u8ba4\u6253\u5305\u7684\u8def\u5f84\u4e3a\u7edd\u5bf9\u8def\u5f84\uff0c\u6539\u4e3a\u76f8\u5bf9\u8def\u5f84\u3002\u4fee\u6539 config\/index.js \u4e2d build \u8282\u70b9\u4e0b assetsPublicPath\uff0c\u628a\u539f\u6765 \u2018\/\u2019 \u6539\u4e3a \u2018.\/\u2019<\/p>\n<pre>build: {\r\n    assetsPublicPath: '.\/'\r\n}\r\n<\/pre>\n<p>2\u3001img \u8def\u5f84\u95ee\u9898<\/p>\n<p>\u5728 build\/utils.js \u6587\u4ef6\u4e2d ExtractTextPlugin extract \u8282\u70b9\u4e0b\uff0c\u6dfb\u52a0\u4e00\u884c\uff1apublicPath: \u2018\u2026\/\u2026\/\u2019<\/p>\n<pre>if (options.extract) {\r\n    return ExtractTextPlugin.extract({\r\n        use: loaders,\r\n        fallback: 'vue-style-loader',\r\n        publicPath: '..\/..\/'\r\n    })\r\n} else {\r\n    return ['vue-style-loader'].concat(loaders)\r\n}<\/pre>\n<p>3\u3001favicon.ico \u95ee\u9898<\/p>\n<p>\u2460 \u5728 build\/webpack.prod.conf.js \u6587\u4ef6\u4e2d new HtmlWebpackPlugin \u8282\u70b9\u4e0b\uff0c \u6dfb\u52a0\u4e00\u884c\uff1afavicon: config.build.favicon<\/p>\n<pre>new HtmlWebpackPlugin({\r\n    filename: config.build.index,\r\n    template: 'index.html',\r\n    favicon: config.build.favicon\r\n})<\/pre>\n<p>\u2461 \u5728 config\/index.js \u6587\u4ef6\u4e2d build \u8282\u70b9\u4e0b\uff0c\u6dfb\u52a0\u4e00\u884c \uff1a favicon:path.resolve( __dirname, \u2018\u2026\/src\/favicon.ico\u2019 )( PS\uff1afavicon.ico \u653e\u5728 src \u76ee\u5f55\u4e0b)<\/p>\n<pre>module.exports = {\r\n    build: {      \r\n       favicon:path.resolve(__dirname, '..\/src\/favicon.ico')\r\n    }\r\n}<\/pre>\n<p>4\u3001IE9+ \u517c\u5bb9\u6027\u95ee\u9898<\/p>\n<p>\u7531\u4e8e axios \u662f\u57fa\u4e8e promise \u4e4b\u4e0a\u5b9e\u73b0\u7684\uff0c\u5728 IE \u4e0b\u4f1a\u6709\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<p>\u2460 \u5b89\u88c5 babel-polyfill<\/p>\n<pre>yarn add babel-polyfill<\/pre>\n<p>\u2461 \u4fee\u6539 build\/webpack.base.conf.js \u6587\u4ef6\u4e2d entry \u8282\u70b9<\/p>\n<pre>entry: {\r\n    app: ['babel-polyfill', '.\/src\/main.js']\r\n}<\/pre>\n<p>5\u3001\u7981\u6b62\u751f\u6210 .map \u6587\u4ef6<\/p>\n<p>\u4fee\u6539 src\/config\/index.js \u4e2d productionSourceMap \u503c<\/p>\n<pre>productionSourceMap:false<\/pre>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=2840\">Vue\u9879\u76ee\u6253\u5305\u5e38\u89c1\u95ee\u9898\u6574\u7406<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Vue \u9879\u76ee\u5728\u5f00\u53d1\u65f6\u8fd0\u884c\u6b63\u5e38\uff0c\u6253\u5305\u53d1\u5e03\u540e\u5374\u51fa\u73b0\u5404\u79cd\u62a5\u9519\uff0c\u8fd9\u91cc\u6574\u7406\u4e00\u4e0b\u9047\u5230\u7684\u95ee\u9898\uff0c\u4ee5\u5907\u5fd8\u3002 1\u3001js \u8def\u5f84\u95ee\u9898 \u811a\u624b\u67b6\u9ed8\u8ba4\u6253\u5305\u7684\u8def\u5f84\u4e3a\u7edd\u5bf9\u8def\u5f84\uff0c\u6539\u4e3a\u76f8\u5bf9\u8def\u5f84\u3002\u4fee\u6539 config\/index.js \u4e2d b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[390],"tags":[26],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/2840"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2840"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/2840\/revisions"}],"predecessor-version":[{"id":2841,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/2840\/revisions\/2841"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2840"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}