从名称空间引用变量时,LESS CSS语法错误 [英] LESS css syntax error when referencing variable from namespace

查看:113
本文介绍了从名称空间引用变量时,LESS CSS语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从LESS中的命名空间引用变量时遇到语法错误:

I'm getting a syntax error when attempting to reference a variable from a namespace in LESS:

#testns {
    @my_color: #04ffff;
    .me() {
        color: blue;
    }
}

.fun {
    color: #testns[@my_color];
}

如果执行以下操作,mixin可以正常工作:

The mixin works fine if I do the following:

.fun {
    #testns > .me();
}

但是由于某种原因,我无法从命名空间中引用变量.我正在使用asual库在Java中构建这些文件,其他所有东西都运行良好.

But I'm not able to reference the variable from the namespace for some reason. I'm building these in Java using the asual library, and everything else is working perfectly.

推荐答案

这不是名称空间的工作方式.命名空间使您可以声明局部混合变量中使用的局部作用域变量(有点像CSS闭包,ha!),并且可以从命名空间包外部引用混合变量.但是,名称空间内部的变量是私有的,不能从名称空间外部进行引用.

This isn't how namespaces work. Namespaces allow you to declare local-scope variables to use in mixins (sort of like a CSS closure, ha!), and the mixins can be referenced from outside the namespace bundle. The variable inside the namespace are private, however, and cannot be referenced from outside the namespace.

这篇关于从名称空间引用变量时,LESS CSS语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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