{"id":27982,"date":"2024-11-24T11:41:40","date_gmt":"2024-11-24T03:41:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27982\/"},"modified":"2024-11-24T11:41:40","modified_gmt":"2024-11-24T03:41:40","slug":"%e5%a6%82%e4%bd%95%e4%bc%98%e9%9b%85%e5%9c%b0%e5%9c%a8-sass-%e4%b8%ad%e4%bd%bf%e7%94%a8%e5%87%bd%e6%95%b0%ef%bc%9a%e6%97%a2%e5%8f%af%e4%bc%a0%e5%8f%82%ef%bc%8c%e5%8f%88%e6%97%a0%e9%87%8d%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27982\/","title":{"rendered":"\u5982\u4f55\u4f18\u96c5\u5730\u5728 Sass \u4e2d\u4f7f\u7528\u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173137513045345.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f18\u96c5\u5730\u5728 Sass \u4e2d\u4f7f\u7528\u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f18\u96c5\u5730\u5728 Sass \u4e2d\u4f7f\u7528\u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f18\u96c5\u5730\u4f7f\u7528 sass \u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d<\/strong><\/p>\n<p>\u5728 sass \u4e2d\uff0c\u4f7f\u7528 mixin \u53ef\u80fd\u4f1a\u5e26\u6765\u4ee3\u7801\u91cd\u590d\u7684\u95ee\u9898\uff0c\u800c %placeholder \u867d\u7136\u4e0d\u4f1a\u91cd\u590d\uff0c\u4f46\u5374\u65e0\u6cd5\u4f20\u53c2\u3002\u90a3\u4e48\uff0c\u6709\u6ca1\u6709\u4e00\u79cd\u65e2\u80fd\u4f20\u53c2\u53c8\u4e0d\u91cd\u590d\u7684\u51fd\u6570\u89e3\u51b3\u65b9\u6848\u5462\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a\u4f7f\u7528 mixin \u4e0e %placeholder \u7ed3\u5408<\/strong><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06 mixin \u4e0e %placeholder \u7ed3\u5408\u4f7f\u7528\uff0c\u65e2\u80fd\u5b9e\u73b0\u4f20\u53c2\uff0c\u53c8\u907f\u514d\u4ee3\u7801\u91cd\u590d\u3002<\/p>\n<pre>%my-placeholder {\n  \/* \u5728\u8fd9\u91cc\u5b9a\u4e49\u901a\u7528\u6837\u5f0f *\/\n}\n\n@mixin myMixin($param1, $param2) {\n  @extend %my-placeholder;\n\n  \/* \u6839\u636e\u4f20\u5165\u7684\u53c2\u6570\u5e94\u7528\u7279\u5b9a\u6837\u5f0f *\/\n  property: value;\n}\n\n.myClass {\n  @include myMixin($value1, $value2);\n}\n\n.anotherClass {\n  @include myMixin($differentValue1, $differentValue2);\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728 %my-placeholder \u4e2d\u5b9a\u4e49\u901a\u7528\u6837\u5f0f\uff0c\u800c\u5728 mymixin \u4e2d\u901a\u8fc7 @extend \u7ee7\u627f\u8fd9\u4e9b\u901a\u7528\u6837\u5f0f\uff0c\u5e76\u6839\u636e\u4f20\u5165\u7684\u53c2\u6570\u5e94\u7528\u7279\u5b9a\u7684\u6837\u5f0f\u3002\u8fd9\u6837\uff0c\u6bcf\u4e2a\u7c7b\u90fd\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5b9a\u5236\u6837\u5f0f\uff0c\u540c\u65f6\u907f\u514d\u4ee3\u7801\u91cd\u590d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f18\u96c5\u5730\u5728 Sass \u4e2d\u4f7f\u7528\u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d\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>\u4f18\u96c5\u5730\u4f7f\u7528 sass \u51fd\u6570\uff1a\u65e2\u53ef\u4f20\u53c2\uff0c\u53c8\u65e0\u91cd\u590d \u5728 sass \u4e2d\uff0c\u4f7f\u7528 mixin \u53ef\u80fd\u4f1a\u5e26\u6765\u4ee3\u7801\u91cd\u590d\u7684\u95ee\u9898\uff0c\u800c %placeholder \u867d\u7136\u4e0d\u4f1a\u91cd\u590d\uff0c\u4f46\u5374\u65e0\u6cd5\u4f20\u53c2\u3002\u90a3\u4e48\uff0c\u6709\u6ca1\u6709\u4e00\u79cd\u65e2\u80fd\u4f20\u53c2\u53c8\u4e0d\u91cd\u590d\u7684\u51fd\u6570\u89e3\u51b3\u65b9\u6848\u5462\uff1f \u7b54\u6848\uff1a\u4f7f\u7528 mixin \u4e0e %placeholder \u7ed3\u5408 \u6211\u4eec\u53ef\u4ee5\u5c06 mixin \u4e0e %placeholder \u7ed3\u5408\u4f7f\u7528\uff0c\u65e2\u80fd\u5b9e\u73b0\u4f20\u53c2\uff0c\u53c8\u907f\u514d\u4ee3\u7801\u91cd\u590d\u3002 %my-placeholder { \/* \u5728\u8fd9\u91cc\u5b9a\u4e49\u901a\u7528\u6837\u5f0f *\/ } @mixin myMixin($param1, $param2) { @extend %my-placeholder; \/* \u6839\u636e\u4f20\u5165\u7684\u53c2\u6570\u5e94\u7528\u7279\u5b9a\u6837\u5f0f *\/ property: value; } .myClass { @include myMixin($value1, $value2); } .anotherClass { @include myMixin($differentValue1, $differentValue2); } \u767b\u5f55\u540e\u590d\u5236 \u5728 %my-placeholder \u4e2d\u5b9a\u4e49\u901a\u7528\u6837\u5f0f\uff0c\u800c\u5728 mymixin [&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-27982","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27982","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=27982"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27982\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}