我想保持我的 sass 代码简短。
代替
@mixin tg($font-size,$line-height) {
something related to font-size and line-height
}
@mixin h1 {
@include tg
}
@mixin h2 {
@include tg
}
....
如何使用循环创建@mixin lib?
$typography-list: h1, h2......
@mixin tg($font-size,$line-height) {
something related to font-size and line-height
}
@each $typography in $typography-list {
create @mixin {
@include tg()
}
}
如果是这样,最好的方法是什么?
最佳答案
实质上,您指的是SCSS
生产SCSS
.这称为 元编程 .在 SASS
中是不可能的.除非 SASS 发明了一些技术或者你有另一种编译为 SCSS
的语言。 .
简而言之,目前,您不能这样做。
关于sass - 如何在sass中使用循环生成多个mixin(mixin lib),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39380955/