【问题标题】:Stylus error: "expected "indent", got "outdent", possibly because of invalid interpolation手写笔错误:“预期为“缩进”,得到“缩进”,可能是因为插值无效
【发布时间】:2020-04-24 02:33:30
【问题描述】:

手写笔代码:

Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
  width {$width}px
  height {$height}px
  background-position -{$positiveXCoordinate}px -{$positiveYCoordinate}px

错误:

   157| Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
   158|   width {$width}px
   159|   height {$height}px
   160|   background-position -{$positiveXCoordinate}px -{$positiveYCoordinate}px
   161| 
--------^

expected "indent", got "outdent"
  • 如果从文件中删除上述代码,错误将消失。
  • IDE 自动在文件末尾添加行(但由于前面的子句,这似乎不是原因)
  • Stylus online 也不编译。

我试图找到文件中的所有空格:

更新:实验

作品:

Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
  width 2px

expected "indent", got "outdent" 失败:

Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
  width {$width}px

看起来插值无效,我没有找到示例,在这种情况下如何插值。

【问题讨论】:

  • 如果您在缩进中混合使用制表符和空格,可能会导致错误消息。
  • @AliAli,感谢您的评论。也许你是对的,但我还没有确认。我将实验结果添加到问题字段中。

标签: css stylus


【解决方案1】:

official doc 的信息不多...你可以试试

Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
  width: $width * 1px

【讨论】:

    【解决方案2】:

    经过大量的实验,我让它起作用了。并且对 Stylus 有点失望。

    Sprite($positiveXCoordinate, $positiveYCoordinate, $width, $height)
      width $width px
      height $height px
      background-position: -($positiveXCoordinate)px (-($positiveYCoordinate)px)
    

    这里,冒号需要在background-position 之后。此外,如果要从(-($positiveYCoordinate)px) 中删除最外面的括号,Stylus 会将$positiveXCoordinate$positiveYCoordinate 计算为单个值。

    附加信息:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 2023-03-22
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多