Generate random number in LESS CSS?

后端 未结 2 1055
忘掉有多难
忘掉有多难 2020-12-01 23:50

Tried searching for this but it\'s difficult given the syntax. Is there any way to generate a random number in LESS? I checked the documentation and don\'t see anything, b

2条回答
  •  长情又很酷
    2020-12-02 00:29

    According to the documentation:

    JavaScript evaluation JavaScript expressions can be evaluated as values inside .less files. We recommend using caution with this feature as the LESS will not be compilable by ports and it makes the LESS harder to maintain. If possible, try to think of a function that can be added to achieve the same purpose and ask for it on github. We have plans to allow expanding the default functions available. However, if you still want to use JavaScript in .less, this is done by wrapping the expression with back-ticks:

    So this should work:

    @var: `Math.random()`;
    

提交回复
热议问题