{"id":26301,"date":"2024-11-24T12:20:27","date_gmt":"2024-11-24T04:20:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26301\/"},"modified":"2024-11-24T12:20:27","modified_gmt":"2024-11-24T04:20:27","slug":"vue2-%e9%a1%b9%e7%9b%ae%e4%b8%ad%ef%bc%8ciconfont-%e6%96%87%e4%bb%b6%e5%a4%b9%e5%ba%94%e8%af%a5%e6%94%be%e5%9c%a8%e5%93%aa%e9%87%8c%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26301\/","title":{"rendered":"Vue2 \u9879\u76ee\u4e2d\uff0ciconfont \u6587\u4ef6\u5939\u5e94\u8be5\u653e\u5728\u54ea\u91cc\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173088091356199.jpg\" class=\"aligncenter\" title=\"Vue2 \u9879\u76ee\u4e2d\uff0ciconfont \u6587\u4ef6\u5939\u5e94\u8be5\u653e\u5728\u54ea\u91cc\uff1f\u63d2\u56fe\" alt=\"Vue2 \u9879\u76ee\u4e2d\uff0ciconfont \u6587\u4ef6\u5939\u5e94\u8be5\u653e\u5728\u54ea\u91cc\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>iconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u4f4d\u7f6e<\/strong><\/p>\n<p>\u5728Vue2\u9879\u76ee\u4e2d\u4f7f\u7528iconfont\u65f6\uff0ciconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u4f4d\u7f6e\u6709\u4e24\u79cd\u9009\u62e9\uff1apublic\u6587\u4ef6\u5939\u548cassets\u6587\u4ef6\u5939\u3002<\/p>\n<p><strong>1. public\u6587\u4ef6\u5939\u8fd8\u662fassets\u6587\u4ef6\u5939\uff1f<\/strong><\/p>\n<ul>\n<li> <strong>public\u6587\u4ef6\u5939\uff1a<\/strong>\u5305\u542b\u8981\u5206\u53d1\u7ed9\u7528\u6237\u7684\u9759\u6001\u6587\u4ef6\uff0c\u5728\u5b89\u88c5\u65f6\u4f1a\u88ab\u5f15\u7528\u3002<\/li>\n<li> <strong>assets\u6587\u4ef6\u5939\uff1a<\/strong>\u7528\u4e8e\u5b58\u50a8\u9879\u76ee\u4e2d\u4f7f\u7528\u7684\u9759\u6001\u6587\u4ef6\uff0c\u5982\u56fe\u50cf\u3001\u5b57\u4f53\u548c\u6837\u5f0f\u8868\u3002<\/li>\n<\/ul>\n<p>iconfont\u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\u5c5e\u4e8e\u9759\u6001\u8d44\u6e90\uff0c\u56e0\u6b64\u53ef\u4ee5\u653e\u5728public\u6216assets\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<p><strong>2. assets\u6587\u4ef6\u5939\u4e2d\u7684\u5f15\u7528\u9519\u8bef<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5982\u679c\u5c06iconfont\u6587\u4ef6\u5939\u653e\u5728assets\u6587\u4ef6\u5939\u4e2d\uff0c\u5e76\u4e14\u5728npm run\u540e\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\uff1a<\/p>\n<ul>\n<li>\u6587\u4ef6\u8def\u5f84\u4e0d\u6b63\u786e<\/li>\n<li>\u6587\u4ef6\u540d\u4e0d\u6b63\u786e<\/li>\n<li>\u6587\u4ef6\u672a\u5305\u542b\u5728webpack\u7684\u5904\u7406\u8303\u56f4\u4e2d\uff08\u672a\u5728webpack\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\uff09<\/li>\n<\/ul>\n<p><strong>3. index.html\u548cmn.js\u4e2d\u7684\u5f15\u7528<\/strong><\/p>\n<p>\u5728index.html\u548cmain.js\u4e2d\u5f15\u7528iconfont.\u6ca1\u6709\u672c\u8d28\u533a\u522b\u3002\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u90fd\u53ef\u4ee5\uff1a<\/p>\n<ul>\n<li>\n<p>\u5728index.html\u4e2d\u5f15\u7528\uff1a<\/p>\n<pre>&lt;link rel=\"stylesheet\" href=\".\/iconfont\/iconfont.css\"&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u5728main.js\u4e2d\u5f15\u7528\uff1a<\/p>\n<pre>import \".\/iconfont\/iconfont.css\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p>\u9009\u62e9\u5728index.html\u8fd8\u662fmain.js\u4e2d\u5f15\u7528\u53d6\u51b3\u4e8e\u52a0\u8f7d\u987a\u5e8f\u548c\u7f16\u7801\u4e60\u60ef\u3002\u7136\u800c\uff0c\u5728Vue\u9879\u76ee\u4e2d\uff0c\u5c06\u5176\u653e\u5728main.js\u4e2d\u66f4\u5e38\u89c1\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7ec4\u4ef6\u53ef\u4ee5\u72ec\u7acb\u52a0\u8f7d\u8d44\u6e90\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fVue2 \u9879\u76ee\u4e2d\uff0ciconfont \u6587\u4ef6\u5939\u5e94\u8be5\u653e\u5728\u54ea\u91cc\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>iconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u4f4d\u7f6e \u5728Vue2\u9879\u76ee\u4e2d\u4f7f\u7528iconfont\u65f6\uff0ciconfont\u6587\u4ef6\u5939\u7684\u653e\u7f6e\u4f4d\u7f6e\u6709\u4e24\u79cd\u9009\u62e9\uff1apublic\u6587\u4ef6\u5939\u548cassets\u6587\u4ef6\u5939\u3002 1. public\u6587\u4ef6\u5939\u8fd8\u662fassets\u6587\u4ef6\u5939\uff1f public\u6587\u4ef6\u5939\uff1a\u5305\u542b\u8981\u5206\u53d1\u7ed9\u7528\u6237\u7684\u9759\u6001\u6587\u4ef6\uff0c\u5728\u5b89\u88c5\u65f6\u4f1a\u88ab\u5f15\u7528\u3002 assets\u6587\u4ef6\u5939\uff1a\u7528\u4e8e\u5b58\u50a8\u9879\u76ee\u4e2d\u4f7f\u7528\u7684\u9759\u6001\u6587\u4ef6\uff0c\u5982\u56fe\u50cf\u3001\u5b57\u4f53\u548c\u6837\u5f0f\u8868\u3002 iconfont\u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\u5c5e\u4e8e\u9759\u6001\u8d44\u6e90\uff0c\u56e0\u6b64\u53ef\u4ee5\u653e\u5728public\u6216assets\u6587\u4ef6\u5939\u4e2d\u3002 2. assets\u6587\u4ef6\u5939\u4e2d\u7684\u5f15\u7528\u9519\u8bef \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5982\u679c\u5c06iconfont\u6587\u4ef6\u5939\u653e\u5728assets\u6587\u4ef6\u5939\u4e2d\uff0c\u5e76\u4e14\u5728npm run\u540e\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\uff1a \u6587\u4ef6\u8def\u5f84\u4e0d\u6b63\u786e \u6587\u4ef6\u540d\u4e0d\u6b63\u786e \u6587\u4ef6\u672a\u5305\u542b\u5728webpack\u7684\u5904\u7406\u8303\u56f4\u4e2d\uff08\u672a\u5728webpack\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\uff09 3. index.html\u548cmn.js\u4e2d\u7684\u5f15\u7528 \u5728index.html\u548cmain.js\u4e2d\u5f15\u7528iconfont.\u6ca1\u6709\u672c\u8d28\u533a\u522b\u3002\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u90fd\u53ef\u4ee5\uff1a \u5728index.html\u4e2d\u5f15\u7528\uff1a &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;.\/iconfont\/iconfont.css&#8221;&gt; \u767b\u5f55\u540e\u590d\u5236 \u5728main.js\u4e2d\u5f15\u7528\uff1a import &#8220;.\/iconfont\/iconfont.css&#8221; \u767b\u5f55\u540e\u590d\u5236 \u9009\u62e9\u5728index.html\u8fd8\u662fmain.js\u4e2d\u5f15\u7528\u53d6\u51b3\u4e8e\u52a0\u8f7d\u987a\u5e8f\u548c\u7f16\u7801\u4e60\u60ef\u3002\u7136\u800c\uff0c\u5728Vue\u9879\u76ee\u4e2d\uff0c\u5c06\u5176\u653e\u5728main.js\u4e2d\u66f4\u5e38\u89c1\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7ec4\u4ef6\u53ef\u4ee5\u72ec\u7acb\u52a0\u8f7d\u8d44\u6e90\u3002 \u4ee5\u4e0a\u5c31\u662fVue2 \u9879\u76ee\u4e2d\uff0ciconfont \u6587\u4ef6\u5939\u5e94\u8be5\u653e\u5728\u54ea\u91cc\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-26301","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26301","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=26301"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26301\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}