- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个贴图生成器,它添加了一个后粒子:
@mixin generator {
@each $key, $value in $config {
$infix: '\@#{$key}' !global;
@content
}
}
我在多种情况下使用上面的 mixin 在末尾添加粒子,例如:
.y- {
@include generator {
&-n#{$infix} {
display: none !important;
}
&-in#{$infix} {
display: inline !important;
}
}
}
我收到以下错误:
Invalid CSS after "&-none": expected selector, was "@"\n
我想要的是:
.y-n@key_name1{
display: none !important;
}
.y-n@key_name2{
display: none !important;
}
这仅在我使用 \@
时出现。
我可以在创建类时添加这个粒子,但就像我说的那样,我想在多种情况下使用它并根据条件改变粒子,所以我需要在 mixin 中。
最佳答案
所以这有效...
$config: (
1: 'a',
2: 'b',
3: 'c'
);
@mixin generator {
@each $key, $value in $config {
$infix: '-#{$key}' !global;
@content
}
}
.y- {
@include generator {
&-n#{$infix} {
display: none !important;
}
&-in#{$infix} {
display: inline !important;
}
}
}
查看此 sassmeister https://www.sassmeister.com/gist/324c3c0003a91eb676b00dfe1877cae0
但是一旦你添加..
\@
..到你的 $infix
变量键字符串,它会抛出一个错误!
$infix: '\@#{$key}' !global;
我假设是 \@
破坏了你的 sass/css。
如果您看到 What is the purpose of the '@' symbol in CSS?问题你只能使用 @
符号来表示(例子)...
/* Import another stylesheet from within a stylesheet */
@import url(style2.css);
/* Apply this style only for printing */
@media print {
body {
color: #000;
background: #fff;
}
}
/* Embed a custom web font */
@font-face {
font-family: 'DejaVu Sans';
src: local('DejaVu Sans Regular'), url(/fonts/DejaVuSans.ttf);
}
也许放弃 \@
并且你的 sass 会正常运行?
关于css - 使用转义字符将值从 mixin 传递到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52042410/
乐 mixins具有两个(或更多)性质,在同一个容器中组合多个值,或者值与角色一起。但是,据我所知,没有一种直接的方法可以检查不是由您创建的变量中的“混合性”。 这可能是个伎俩 my $foo = 3
我对 sass 比较陌生,但是当我学习它时,Sass 网站说要开始使用 @use 而不是 import,所以经过大量的反复试验,我终于弄清楚了如何使用它与导入相同。 注意:我使用 Prepros 进行
给定一个看起来像这样的代码片段,我如何编写一个函数来检查给定对象是否实现了某个混合?我尝试使用指针转换,但由于它们具有相同的基础,因此每个结果都是非空的,但我猜测有一个模板化的解决方案,但找不到我可以
我正在使用 Typescript 2.2 的 mixin,并且想使用另一个 mixin 的属性。 文档显示可以将 mixins 限制为仅混合到某些类中...... const WithLocation
我如何创建一个将嵌套的 mixin 属性用作参数的 mixin? 我用下一个例子来解释自己。 我有一个“过渡属性”mixin: .transition-property (@props){ -we
我浏览了language documentation而且 Google Dart 似乎不支持 mixins(接口(interface)中没有方法主体,没有多重继承,没有类似 Ruby 的模块)。我对此
我想编写返回混合的函数/混合。例如我有这个 mixin: @mixin generate-offsets-from-map($class-slug,$type,$from, $to, $step) {
所有 Less 文档和教程都使用 #namespace > .mixin()当它进入命名空间时的语法。但是我发现自己更习惯于 .namespace.mixin()语法,即: .namespace()
我正在努力实现以下目标: class A { def foo() { "foo" } } class B { def bar() { "bar" } } A.mixin B def a = n
出于本问题的目的,将“mixin”视为 https://www.typescriptlang.org/docs/handbook/mixins.html 中所述的函数。 .在这种情况下,mixin 扩
如何在 vue mixins 中组合两个函数? Vue.mixin({ methods: { functionOne: () => { console.log(1)
我需要重写 mixin 添加的一些成员函数来自第三方库。问题是:mixin 立即在多个第 3 方类定义中使用,在定义 mixin 的同一个脚本文件中。我只能在此脚本之前或之后插入自定义代码,而不能在两
我有一些基本的 mixin,它们使用媒体查询应用一些规则 .on-small(@rules) { @media (@minWidthSmall) { @rules(); } } .on-mediu
我尝试安装 npm 包。所有软件包都安装正确。 但是当我尝试使用 npm start 运行应用程序时当时发生以下错误: ERROR in ./node_modules/css-loader?{"sou
这里有两个mixin @mixin parent { .parent & { @content; } } @mixin child($child) { .#{$child} & {
我在另一个 mixins 中有一个 mixins .background(@url: @base-url , @repeat: repeat, @pos1: left, @pos2: center
我有这个: 如您所见,我目前有一个包含按钮样式混合宏的条件,无论如何我可以自动包含一个吗?例如: @mixin button($color) @include button-#{$color} 最
我有以下代码,可以很好地将各种 std::tuples 转发到我的“BaseSensor”主机类的各种 mixin。 #include // std::cout std::endl #include
我按照概述的方式组织我的 sass (scss) 文件 here ... stylesheets/ | |-- modules/ # Common modules | |
所以,这是我的第一个 mixin .3transitions (@value1,@value2,@value3,@duration){ @value: ~"@{value1},@{value2}
我是一名优秀的程序员,十分优秀!