{"id":1357,"date":"2024-11-10T14:13:21","date_gmt":"2024-11-10T06:13:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1357\/"},"modified":"2024-11-10T14:13:21","modified_gmt":"2024-11-10T06:13:21","slug":"%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0-vue-3-%e9%a1%b9%e7%9b%ae%e4%b8%ad%e7%89%b9%e5%ae%9a%e9%a1%b5%e9%9d%a2%e8%87%aa%e9%80%82%e5%ba%94%ef%bc%8c%e9%81%bf%e5%85%8d%e5%bd%b1%e5%93%8d%e5%85%a8%e5%b1%80-ui","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1357\/","title":{"rendered":"\u5982\u4f55\u5b9e\u73b0 Vue 3 \u9879\u76ee\u4e2d\u7279\u5b9a\u9875\u9762\u81ea\u9002\u5e94\uff0c\u907f\u514d\u5f71\u54cd\u5168\u5c40 UI \u6846\u67b6\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173037768790670.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0 Vue 3 \u9879\u76ee\u4e2d\u7279\u5b9a\u9875\u9762\u81ea\u9002\u5e94\uff0c\u907f\u514d\u5f71\u54cd\u5168\u5c40 UI \u6846\u67b6\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5b9e\u73b0 Vue 3 \u9879\u76ee\u4e2d\u7279\u5b9a\u9875\u9762\u81ea\u9002\u5e94\uff0c\u907f\u514d\u5f71\u54cd\u5168\u5c40 UI \u6846\u67b6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u81ea\u9002\u5e94\u9875\u9762 px \u5230 rem \u63d2\u4ef6\u63a2\u7d22<\/strong><\/p>\n<p>\u5728  3 \u9879\u76ee\u4e2d\uff0c\u5f00\u53d1\u8005\u6709\u65f6\u9700\u8981\u8ba9\u67d0\u4e2a\u7279\u5b9a\u9875\u9762\u5177\u6709\u81ea\u9002\u5e94\u5927\u5c0f\uff0c\u5373\u6839\u636e\u4e0d\u540c\u5206\u8fa8\u7387\u81ea\u52a8\u8c03\u6574 px \u5230 rem \u7684\u8f6c\u6362\u3002\u7136\u800c\uff0c\u4f20\u7edf\u7684 px-to-rem \u63d2\u4ef6\u53ef\u80fd\u4f1a\u5f71\u54cd\u6574\u4e2a\u9879\u76ee\u7684 ui \u6846\u67b6\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u91cc\u63d0\u4f9b\u4e86\u4e00\u79cd\u5229\u7528 javascript \u548c  \u63d2\u4ef6\u76f8\u7ed3\u5408\u7684\u65b9\u6cd5\uff0c\u5b9e\u73b0\u9875\u9762\u81ea\u9002\u5e94\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u83b7\u53d6\u9875\u9762\u5bbd\u5ea6\u548c\u57fa\u7840\u503c\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u4f7f\u7528 javascript \u83b7\u53d6\u9875\u9762\u7684\u5bbd\u5ea6\uff0c\u5e76\u8bbe\u7f6e\u4e00\u4e2a\u57fa\u7840\u503c\uff08\u4f8b\u5982 375\uff0c\u5373\u8bbe\u8ba1\u56fe\u7684\u5bbd\u5ea6\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 vscode \u63d2\u4ef6 px2rem\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 vscode \u4e2d\u5b89\u88c5 px2rem \u63d2\u4ef6\u3002\u8be5\u63d2\u4ef6\u53ef\u4ee5\u5728 px \u548c rem \u5355\u4f4d\u4e4b\u95f4\u8fdb\u884c\u81ea\u52a8\u8f6c\u6362\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728\u9875\u9762\u751f\u547d\u5468\u671f\u4e2d\u8c03\u6574\u5b57\u4f53\u5927\u5c0f\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u9875\u9762\u7684 mounted \u751f\u547d\u5468\u671f\u94a9\u5b50\u4e2d\uff0c\u6839\u636e\u4e0a\u8ff0\u57fa\u7840\u503c\u8ba1\u7b97\u5b57\u4f53\u5927\u5c0f\u3002<\/li>\n<li>\u8c03\u6574 html \u5143\u7d20\u7684 font-size\uff0c\u4e3a\u5176\u4ed6\u5355\u4f4d\u7684\u8f6c\u6362\u5960\u5b9a\u57fa\u7840\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5c06\u9875\u9762\u5355\u4f4d\u66f4\u6539\u4e3a rem\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u9875\u9762\u4e2d\u5c06\u6240\u6709\u5355\u4f4d\uff08\u5305\u62ec\u5b57\u4f53\u3001\u95f4\u8ddd\u7b49\uff09\u4ece px \u6539\u4e3a rem\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>let appWidth = $('#app').width()\nlet size = (appWidth \/ 375) * 10\ndocument.documentElement.style.fontSize = size + 'px'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4ec5\u5bf9\u7279\u5b9a\u9875\u9762\u5e94\u7528\u81ea\u9002\u5e94\u8f6c\u6362\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u9875\u9762\u6216\u9879\u76ee\u5168\u5c40\u6837\u5f0f\u3002\u5b83\u4f7f\u7528 javascript \u83b7\u53d6\u5bbd\u5ea6\u5e76\u52a8\u6001\u8ba1\u7b97\u5b57\u4f53\u5927\u5c0f\uff0c\u7ed3\u5408 px2rem \u63d2\u4ef6\u8f6c\u6362\u5176\u4ed6\u5355\u4f4d\uff0c\u4ece\u800c\u5b9e\u73b0\u5168\u90e8\u81ea\u9002\u5e94\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5b9e\u73b0 Vue 3 \u9879\u76ee\u4e2d\u7279\u5b9a\u9875\u9762\u81ea\u9002\u5e94\uff0c\u907f\u514d\u5f71\u54cd\u5168\u5c40 UI \u6846\u67b6\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>\u81ea\u9002\u5e94\u9875\u9762 px \u5230 rem \u63d2\u4ef6\u63a2\u7d22 \u5728 3 \u9879\u76ee\u4e2d\uff0c\u5f00\u53d1\u8005\u6709\u65f6\u9700\u8981\u8ba9\u67d0\u4e2a\u7279\u5b9a\u9875\u9762\u5177\u6709\u81ea\u9002\u5e94\u5927\u5c0f\uff0c\u5373\u6839\u636e\u4e0d\u540c\u5206\u8fa8\u7387\u81ea\u52a8\u8c03\u6574 px \u5230 rem \u7684\u8f6c\u6362\u3002\u7136\u800c\uff0c\u4f20\u7edf\u7684 px-to-rem \u63d2\u4ef6\u53ef\u80fd\u4f1a\u5f71\u54cd\u6574\u4e2a\u9879\u76ee\u7684 ui \u6846\u67b6\u3002 \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u91cc\u63d0\u4f9b\u4e86\u4e00\u79cd\u5229\u7528 javascript \u548c \u63d2\u4ef6\u76f8\u7ed3\u5408\u7684\u65b9\u6cd5\uff0c\u5b9e\u73b0\u9875\u9762\u81ea\u9002\u5e94\uff1a \u83b7\u53d6\u9875\u9762\u5bbd\u5ea6\u548c\u57fa\u7840\u503c\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 javascript \u83b7\u53d6\u9875\u9762\u7684\u5bbd\u5ea6\uff0c\u5e76\u8bbe\u7f6e\u4e00\u4e2a\u57fa\u7840\u503c\uff08\u4f8b\u5982 375\uff0c\u5373\u8bbe\u8ba1\u56fe\u7684\u5bbd\u5ea6\uff09\u3002 \u4f7f\u7528 vscode \u63d2\u4ef6 px2rem\uff1a \u5728 vscode \u4e2d\u5b89\u88c5 px2rem \u63d2\u4ef6\u3002\u8be5\u63d2\u4ef6\u53ef\u4ee5\u5728 px \u548c rem \u5355\u4f4d\u4e4b\u95f4\u8fdb\u884c\u81ea\u52a8\u8f6c\u6362\u3002 \u5728\u9875\u9762\u751f\u547d\u5468\u671f\u4e2d\u8c03\u6574\u5b57\u4f53\u5927\u5c0f\uff1a \u5728\u9875\u9762\u7684 mounted \u751f\u547d\u5468\u671f\u94a9\u5b50\u4e2d\uff0c\u6839\u636e\u4e0a\u8ff0\u57fa\u7840\u503c\u8ba1\u7b97\u5b57\u4f53\u5927\u5c0f\u3002 \u8c03\u6574 html \u5143\u7d20\u7684 font-size\uff0c\u4e3a\u5176\u4ed6\u5355\u4f4d\u7684\u8f6c\u6362\u5960\u5b9a\u57fa\u7840\u3002 \u5c06\u9875\u9762\u5355\u4f4d\u66f4\u6539\u4e3a rem\uff1a \u5728\u9875\u9762\u4e2d\u5c06\u6240\u6709\u5355\u4f4d\uff08\u5305\u62ec\u5b57\u4f53\u3001\u95f4\u8ddd\u7b49\uff09\u4ece px \u6539\u4e3a rem\u3002 \u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a let [&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-1357","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1357","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=1357"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1357\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}