在属性选择器表达式中将变量混入属性名称中 [英] LESS mix variable into attribute name in an attribute selector expression

查看:47
本文介绍了在属性选择器表达式中将变量混入属性名称中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何正确实现以下语法?

How can I implement the following syntax correctly?

.jacket(@classname, @attrname, @value) {
    .class-prefix-@{classname}[some-prefix-@{attrname}~="@{value}"] {
        //                                 ^Error From Here
        // Attributes
    }
}

lessc显示存在 SyntaxError:预期的']'得到了'@'

lessc shows that there is an SyntaxError: expected ']' got '@'

推荐答案

实际上看起来像是一个错误,这个解决方法应该可以解决问题:

It seems like a bug actually, this workaround should do the trick:

.jacket(@classname, @attrname, @value) {
    @attr: ~'some-prefix-@{attrname}';
    .class-prefix-@{classname}[@{attr}~="@{value}"] {
        // ...
    }
}

这篇关于在属性选择器表达式中将变量混入属性名称中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆