css - 减:不能在每个内部使用 Map
问题描述
我有以下更少:
@threshold:{
a:50;
b:200;
};
@themes:{
a:red;
b:blue;
};
.mymixin(@name,@color,@thrshld){
//do-something
}
each(@themes,{
.mymixin(@key,@value,@threshold[@key]);
});
通过运行代码,出现以下错误:
RuntimeError:错误评估函数
each
:未找到变量@key...
我正在使用 v3.9.0
如何在每个功能中使用地图?
解决方案
您需要使用@map[$@property]
语法来评估@map[@property]
.mymixin(@name, @color, @thrshld) {
.theme-@{name} {
color: @color;
width: @thrshld;
}
}
@threshold: {
a: 50;
b: 200;
};
@themes: {
a: red;
b: blue;
};
each(@themes, {
.mymixin(@key, @value, @threshold[$@key])
})
推荐阅读
- python - 使用 docker 开发时运行预提交挂钩(例如 pylint)
- flutter - 许多 BlocListener 在 Flutter 上注册了 Navigation.pushName()
- python - 为什么我在 Django 中收到“MySQL 服务器已消失”异常?
- sonarqube - SonarQube 7.1 - Debian 安装 - 连接被拒绝
- ruby-on-rails - 弃用警告:ActionView::Base 实例应使用查找上下文、分配和控制器构造
- php - 根据用户选择跨多个页面显示正确的下载表单
- docker - docker-compose.yml 不会读取主机名的环境变量
- spring - 如何注册外部注释以供弹簧验证使用
- python - 格式化 yaml 以包含嵌套字典?
- react-native - 抽屉中的图像不显示在 react-native