我决定从SCSS => Stylus切换到预编译程序。我已经看过了Stylus的文档,但遇到了麻烦。
手写笔列表:
breakpoints = xs 176px,
s 480px,
m 768px此列表如下所示:
respond-to()
if arguments in breakpoints
@media (min-width: arguments)
{block}
else
error('Invalid breakpoint.')和这样的参考资料
respond-to(xs)
col()但这没什么结果。
我不想迭代每个数组项并输出它们,我只想将用户定义的密钥名与数组中的键名匹配,如果数组中存在,则将其单个值输出到语句中,否则出现错误,如上面所示。
代码是合乎逻辑的,有什么想法吗?
编辑#1:尝试将列表转换为散列,并使用相同的pull语句,没有结果
哈希:
breakpoints = { 'xs': 176px, 's': 480px, 'm ': 768px }拉:
respond-to()
if arguments in breakpoints
@media (min-width: breakpoints[arguments])
{block}
else
error('Invalid breakpoint.')编辑2:找到一些与我想做的类似的东西,只是不想要那么多代码。CTRL //定义缓存和别名这里。
编辑#3:找到一个具有相同用法的NPM图书馆
发布于 2015-04-20 14:54:35
arguments是一个传递参数的list,因此您应该使用[0]来获取第一个参数。或者你可以直接说出论点的名字。例如:
breakpoints = { 'xs': 176px, 's': 480px, 'm ': 768px }
respond-to() // or respond-to(bp) and delete the second line
bp = arguments[0]
if bp in breakpoints
@media (min-width: breakpoints[bp])
{block}
else
error('Invalid breakpoint.')
+respond-to('xs') // the + sign is important because it's a block mixin call
body
color redhttps://stackoverflow.com/questions/29739048
复制相似问题