简体   繁体   English

如何在LESS中将值传递给变量?

[英]How can I pass a value to a variable in LESS?

I'd like to pass a value to a variable in LESS. 我想将值传递给LESS中的变量。 How can I do this? 我怎样才能做到这一点?

Here's some sample code. 这是一些示例代码。 I'd like to pass the values in .className() to the variable @varValue . 我想将.className()的值传递给变量@varValue

@defaultWidth: 10px;
.className(@varValue: 1) {
    width: (@defaultWidth * @varValue);
    background: green;
}

.sample {

    background: blue;
    height: 10px;

    .filled_1     { .className(1); }
    .filled_2     { .className(2); }
    .filled_3     { .className(3); }
}

Example HTML: HTML示例:

<div class="sample">
    <div class="filled_3"></div>
</div>

As Guy Morgrabi stated in the comment above, it's an issue with different LESS compiler versions. 正如盖伊Morgrabi在上面的评论说,这是不同的LESS编译器版本的问题。 Guy should get the credit, but for the others visiting, you should know the answer. 盖伊应该得到荣誉,但是对于其他来访的人,您应该知道答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取表中单元格的值以传递给PHP中的变量? - How can I get the value of a cell in the table to pass to a variable in PHP? 如何使用 JavaScript 将变量的值传递给文本区域? - How can I pass the value of a variable to a text area using JavaScript? 如何将 HTML 值传递给 PHP 变量 - How can I pass an HTML value to a PHP variable 如何检查变量是否小于ejs中的某个数字 - How can I check if a variable is less then a certain number in ejs 每次我将变量分配给 javascript 中的不同值时,如何将变量传递给 function - How can I pass a variable to a function every time I assign it to a different value in javascript 如何在同一模板中将变量的值从一个div传递到另一个div? - How can I pass the value of variable from one div to another div in the same template? 如何从JSON URL中获取特定值,并将其传递给Javascript变量? - How can I get a specific value from a JSON URL, and pass it into a Javascript variable? 我可以将值传递给同级组件而不将其保存为变量吗? - can I pass a value to a sibling component without saving it as a variable? 如何在 Ajax 中将按钮值作为变量传递? - How do I pass Button Value as a variable in Ajax? 如何将JS变量传递到INPUT语句的“ value =”参数中 - How do I pass a JS variable into the “value=” parameter of an INPUT statement
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM