【问题标题】:How to use .startsWith with SASS如何在 SASS 中使用 .startsWith
【发布时间】:2020-09-11 13:41:36
【问题描述】:

我有一个像这样的 SASS 条件,它按我的预期工作,但是你可以看到它太长了,我想重构它。如何使用 JavaScript 的 startsWith() 或 includes() 原型?

@if $styleName == margin or $styleName == margin-top or $styleName == margin-right or $styleName == margin-bottom or $styleName == margin-left {
//..something happens there
}

我正在寻找类似的解决方案:

@if $styleName.startsWith('margin'){
//..something happens there
}

【问题讨论】:

    标签: css sass node-sass


    【解决方案1】:
    @if str-index($styleName, "margin") {}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-27
      • 1970-01-01
      • 2021-03-27
      • 2020-01-29
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      相关资源
      最近更新 更多