0

在 Stylus 中它很简单split('1/2', '/')[0](它将在某个分隔符处拆分字符串值,在示例中它将返回1),在 Sass 中我需要一个巨大的函数来做到这一点。我看不到在 LESS 中本地执行此操作的方法或在任何地方执行此操作的函数。

有人知道这样做的方法吗?

4

1 回答 1

1

It's silly more of these functions aren't built into preprocessors.

You should possible also explain why you need the split function.

Since Less version 2 you can easily add your own functions, see How to exend the Less compiler with a custom function leveraging a plugin

You should be able to add a split function which returns a list. As already explained by @Amadan you can use this list with loops and the built-in list functions.

于 2015-04-06T08:12:33.560 回答