0
我目前得到這個輸出可以作爲選擇{怎麼做點添加到一個變量在更短的
.teal-dark { color; #xxx; }
這裏是什麼我試圖做的事:
@teal-dark: #xxx;
[email protected]{currentMember} div { background: ~"@{@{currentMember}}" };
我目前得到這個輸出可以作爲選擇{怎麼做點添加到一個變量在更短的
.teal-dark { color; #xxx; }
這裏是什麼我試圖做的事:
@teal-dark: #xxx;
[email protected]{currentMember} div { background: ~"@{@{currentMember}}" };
參見:http://lesscss.org/features/#variables-feature-variable-interpolationhttp://lesscss.org/features/#variables-feature-variable-names和
@current-member: teal-dark;
@teal-dark: red;
[email protected]{current-member} {
color: @@current-member;
}
編譯成:
.teal-dark {
color: red;
}
可能的相關問題:
下面是另一篇文章的修補程序:
@selector: ~'[email protected]{currentMember}';
@{selector} div { background: ~"@{@{currentMember}}" };
該語法可以正常工作,但取決於您是將值分配給'@ currentMember'作爲'teal-dark'還是''teal-dark''。如果您的變量值由於某種原因而引用了引號,那麼您可以使用[this]中提到的方法(http://stackoverflow.com/questions/19614621/less-mixin-output-values-without-quotes/19614647#19614647)answer將其從輸出中刪除。 – Harry
我必須使用字符串,否則它會插入'grey'到'#808080'的顏色,我不想要。 – chovy
有你的伴侶。在那種情況下,我在之前的評論中回答的解決方案中提到的解決方案是最好的選擇。還有更少的v2.0和更高版本不會將顏色名稱轉換爲十六進制代碼自動轉換。所以升級Less編譯器也會有所幫助:) – Harry