{"id":26214,"date":"2024-11-24T11:13:34","date_gmt":"2024-11-24T03:13:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26214\/"},"modified":"2024-11-24T11:13:34","modified_gmt":"2024-11-24T03:13:34","slug":"vue-%e9%a1%b9%e7%9b%ae%e4%b8%ad%e9%98%bf%e9%87%8c-iconfont-%e6%96%87%e4%bb%b6%e8%af%a5%e5%a6%82%e4%bd%95%e6%94%be%e7%bd%ae%e5%92%8c%e5%bc%95%e7%94%a8%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26214\/","title":{"rendered":"Vue \u9879\u76ee\u4e2d\u963f\u91cc iconfont \u6587\u4ef6\u8be5\u5982\u4f55\u653e\u7f6e\u548c\u5f15\u7528\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173086038436369.jpg\" class=\"aligncenter\" title=\"Vue \u9879\u76ee\u4e2d\u963f\u91cc iconfont \u6587\u4ef6\u8be5\u5982\u4f55\u653e\u7f6e\u548c\u5f15\u7528\uff1f\u63d2\u56fe\" alt=\"Vue \u9879\u76ee\u4e2d\u963f\u91cc iconfont \u6587\u4ef6\u8be5\u5982\u4f55\u653e\u7f6e\u548c\u5f15\u7528\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u963f\u91cciconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u53ca\u5f15\u7528<\/strong><\/p>\n<p><strong>1. \u6587\u4ef6\u653e\u7f6e\u4f4d\u7f6e<\/strong><\/p>\n<p>\u963f\u91cciconfont\u6587\u4ef6\u5939\u53ef\u4ee5\u653e\u5728Vue\u9879\u76ee\u7684public\u6216assets\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p>public\u6587\u4ef6\u5939\u7528\u4e8e\u653e\u7f6e\u9759\u6001\u6587\u4ef6\uff0c\u800cassets\u6587\u4ef6\u5939\u5219\u7528\u4e8e\u653e\u7f6e\u9700\u8981webpack\u5904\u7406\u7684\u8d44\u6e90\u3002iconfont\u6587\u4ef6\u662f\u9759\u6001\u6587\u4ef6\uff0c\u56e0\u6b64\u53ef\u4ee5\u653e\u7f6e\u5728public\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p><strong>2. assets\u6587\u4ef6\u5939\u4e0b<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5982\u679c\u60a8\u5c06iconfont\u6587\u4ef6\u5939\u653e\u5728assets\u6587\u4ef6\u5939\u4e0b\uff0c\u5e76\u5728\u8fd0\u884cnpm run\u540e\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3awebpack\u65e0\u6cd5\u6b63\u786e\u5904\u7406\u5b57\u4f53\u6587\u4ef6\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5c06\u5b57\u4f53\u6587\u4ef6\u6392\u9664\u5728webpack\u7684\u5904\u7406\u4e4b\u5916\u3002\u53ef\u4ee5\u5728webpack\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u9879\uff1a<\/p>\n<pre>module.exports = {\n  \/\/ \u5176\u4ed6\u914d\u7f6e\u9879\n  module: {\n    rules: [\n      \/\/ \u5176\u4ed6\u89c4\u5219\n      {\n        test: \/.(woff2?|eot|ttf|otf)(?.*)?$\/,\n        loader: 'file-loader',\n        options: {\n          name: '[name].[ext]',\n          outputPath: 'fonts\/',\n        },\n      },\n    ],\n  },\n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. index.html\u4e0emn.js\u4e2d\u5f15\u7528iconfont.<\/strong><\/p>\n<p>\u5728index.html\u548cmain.js\u4e2d\u5f15\u7528iconfont.css\u6587\u4ef6\u90fd\u53ef\u4ee5\uff0c\u4f46\u52a0\u8f7d\u987a\u5e8f\u548c\u7f16\u7801\u4e60\u60ef\u51b3\u5b9a\u4e86\u653e\u7f6e\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u653e\u5728main.js\u6587\u4ef6\u4e2d\u5f15\u7528\u66f4\u5e38\u89c1\u3002\u56e0\u4e3aVue\u9879\u76ee\u7684\u9875\u9762\u53ef\u80fd\u5728\u7ec4\u4ef6\u4e2d\u5b8c\u6210\uff0c\u5e76\u975e\u5168\u90e8\u5728index.html\u6587\u4ef6\u4e2d\uff0c\u5728\u7ec4\u4ef6\u4e2d\u5f15\u7528\u516c\u5171\u8d44\u6e90\u53ef\u63d0\u9ad8\u4ee3\u7801\u7b80\u6d01\u6027\u548c\u53ef\u79fb\u690d\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue \u9879\u76ee\u4e2d\u963f\u91cc iconfont \u6587\u4ef6\u8be5\u5982\u4f55\u653e\u7f6e\u548c\u5f15\u7528\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>\u963f\u91cciconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u53ca\u5f15\u7528 1. \u6587\u4ef6\u653e\u7f6e\u4f4d\u7f6e \u963f\u91cciconfont\u6587\u4ef6\u5939\u53ef\u4ee5\u653e\u5728Vue\u9879\u76ee\u7684public\u6216assets\u6587\u4ef6\u5939\u4e0b\u3002 public\u6587\u4ef6\u5939\u7528\u4e8e\u653e\u7f6e\u9759\u6001\u6587\u4ef6\uff0c\u800cassets\u6587\u4ef6\u5939\u5219\u7528\u4e8e\u653e\u7f6e\u9700\u8981webpack\u5904\u7406\u7684\u8d44\u6e90\u3002iconfont\u6587\u4ef6\u662f\u9759\u6001\u6587\u4ef6\uff0c\u56e0\u6b64\u53ef\u4ee5\u653e\u7f6e\u5728public\u6587\u4ef6\u5939\u4e0b\u3002 2. assets\u6587\u4ef6\u5939\u4e0b \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5982\u679c\u60a8\u5c06iconfont\u6587\u4ef6\u5939\u653e\u5728assets\u6587\u4ef6\u5939\u4e0b\uff0c\u5e76\u5728\u8fd0\u884cnpm run\u540e\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3awebpack\u65e0\u6cd5\u6b63\u786e\u5904\u7406\u5b57\u4f53\u6587\u4ef6\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5c06\u5b57\u4f53\u6587\u4ef6\u6392\u9664\u5728webpack\u7684\u5904\u7406\u4e4b\u5916\u3002\u53ef\u4ee5\u5728webpack\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u9879\uff1a module.exports = { \/\/ \u5176\u4ed6\u914d\u7f6e\u9879 module: { rules: [ \/\/ \u5176\u4ed6\u89c4\u5219 { test: \/.(woff2?|eot|ttf|otf)(?.*)?$\/, loader: &#8216;file-loader&#8217;, options: { name: &#8216;[name].[ext]&#8217;, outputPath: &#8216;fonts\/&#8217;, }, }, ], }, }; \u767b\u5f55\u540e\u590d\u5236 3. index.html\u4e0emn.js\u4e2d\u5f15\u7528iconfont. \u5728index.html\u548cmain.js\u4e2d\u5f15\u7528iconfont.css\u6587\u4ef6\u90fd\u53ef\u4ee5\uff0c\u4f46\u52a0\u8f7d\u987a\u5e8f\u548c\u7f16\u7801\u4e60\u60ef\u51b3\u5b9a\u4e86\u653e\u7f6e\u7684\u4f4d\u7f6e\u3002 \u4e00\u822c\u6765\u8bf4\uff0c\u653e\u5728main.js\u6587\u4ef6\u4e2d\u5f15\u7528\u66f4\u5e38\u89c1\u3002\u56e0\u4e3aVue\u9879\u76ee\u7684\u9875\u9762\u53ef\u80fd\u5728\u7ec4\u4ef6\u4e2d\u5b8c\u6210\uff0c\u5e76\u975e\u5168\u90e8\u5728index.html\u6587\u4ef6\u4e2d\uff0c\u5728\u7ec4\u4ef6\u4e2d\u5f15\u7528\u516c\u5171\u8d44\u6e90\u53ef\u63d0\u9ad8\u4ee3\u7801\u7b80\u6d01\u6027\u548c\u53ef\u79fb\u690d\u6027\u3002 \u4ee5\u4e0a\u5c31\u662fVue \u9879\u76ee\u4e2d\u963f\u91cc iconfont \u6587\u4ef6\u8be5\u5982\u4f55\u653e\u7f6e\u548c\u5f15\u7528\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26214","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26214","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=26214"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26214\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}