我一直在嘗試將變數的值更改為字串,我已經閱讀并嘗試了一些內置的 SASS 函式。以下面的代碼為例:
$primary-color: rgb(0, 0, 0);
$string: quote($primary-color); // => "#000000"
// But I want to have it as "rgb(0, 0, 0)".
謝謝
uj5u.com熱心網友回復:
$primary-color變數被 SASS 稱為顏色型別,不會保存其格式。通過使用插值 ( #{}) 和sass:color模塊可以達到目標。有關它們的更多資訊,請訪問以下鏈接:
https://sass-lang.com/documentation/interpolation
https://sass-lang.com/documentation/modules/color#red
在下面的代碼中,#{和之間的陳述句}是一個SASS代碼,將由SASS處理。red是獲取顏色的紅色零件編號的函式;也green和它們的顏色功能blue相同red。
$string: "rgb(#{red($primary-color)},#{green($primary-color)},#{blue($primary-color)})"; // => "#000000"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/399299.html
上一篇:從python中的字串中洗掉單詞
