LESS Mixins在其他导入的LESS文件中不可用 [英] LESS Mixins aren't available in other imported LESS files

查看:451
本文介绍了LESS Mixins在其他导入的LESS文件中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码:

@import "vars.less";

// Desktop/Laptop Section
@import "mixins-d-1.less";
@import "positioning.less";
@import "containers-d-1.less";

containers-d-1.less内部,我引用了mixins-d-1.less中的mixin.但是,我收到一条错误消息,说它是未定义的.

Inside containers-d-1.less I reference a mixin from mixins-d-1.less. However, I get an error saying that it's undefined.

我能够将变量从vars.less中拉出,为什么我不能将我的mixins从mixins-d-1.less中拉出?

I'm able to pull my variables out of vars.less, why can't I pull my mixins out of mixins-d-1.less?

推荐答案

问题实际上根本不是导入.

The problem wasn't the importing at all, really.

我在使用媒体查询的方式上犯了一个错误.

I made a mistake in how I was using media queries.

这两个文件都具有相同的媒体查询,因为它们都是针对桌面CSS的(因此为"d").但是,在容器d-1.less中的第二个覆盖了第一个,并吹走了我所有的mixins!我显然需要将import块包装到该部分的单个媒体查询中,而不是在每个较少的文件中重新声明它.

Both files had the same media query since they were both for the desktop CSS (hence the "d"). However, the second one, in containers-d-1.less was OVERWRITING the first one and blowing away all my mixins! I clearly need to wrap the import block in a single media query for that section instead of redeclaring it inside each less file.

这篇关于LESS Mixins在其他导入的LESS文件中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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