【问题标题】:Is there a Sass-style map-keys function in Less?Less 中是否有 Sass 风格的映射键功能?
【发布时间】:2021-07-21 05:48:12
【问题描述】:

我发现 Scss 有 map-keys 函数来获取属性的键:

$properties: (transform: translateX(100%) translate(0%), opacity: 0 1);

transition-property: map-keys($properties);

将输出:

transition-property: transform, opacity;

我试过但没发现少有这个有用的功能。

我正在使用 v3.10.3

如何使用 less 从 Map 中获取密钥?

【问题讨论】:

    标签: sass less


    【解决方案1】:

    我得到了答案:

    @properties: {
      transform: translateX(100%) translate(0%);
      opacity: 0 1;
    };
    
    .extract-prop(@properties) {
      each(@properties, {
        transition-property+: @key;
      })
    }
    
    .extract-prop(@properties);
    

    会得到输出:

    transition-property: transform, opacity;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 2022-09-24
      • 2018-12-01
      相关资源
      最近更新 更多