less mixin name is evaluated to colour/color

前端 未结 1 1141
感动是毒
感动是毒 2021-01-25 08:19

I have a less file to define a bunch of colours/color. Each class name contains the name of the relevant colour, such as .colourOrange{..} or .colourBorderOr

相关标签:
1条回答
  • 2021-01-25 08:56

    This is a legacy feature of Less. For the time being, one of the below work-around solutions could be used to overcome this color name to hex code conversion.

    .completeColour(~"Orange",1);
    

    or

    .completeColour(e("Orange"),1);
    

    Both the options explicitly tell the compiler that the value being passed is a String and not a Color and hence Less compiler would not convert it to the corresponding hex code.

    Sources:

    1. Less GitHub - how to avoid color name be translated into color value?
    2. Less GitHub - Compilation of named colors results in hex values being used incorrectly in interpolations

    Update: Starting from version 2.0.0, this color name to hex code conversion would not happen if the color is mentioned explicitly as a name and has no other color based operations on it. Version 2.0.0 is currently in beta mode.

    (Official Update: V2 Upgrade Guide | Original Source: More consistent named color variables).

    0 讨论(0)
提交回复
热议问题