LESS css syntax error when referencing variable from namespace

99封情书 提交于 2019-12-23 19:17:58

问题


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];
}

The mixin works fine if I do the following:

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/8658270/less-css-syntax-error-when-referencing-variable-from-namespace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!