【问题标题】:SASS ERROR : Properties are only allowed within rules, directives, mixin includes, or other propertiesSASS 错误:属性只允许在规则、指令、mixin 包含或其他属性中
【发布时间】:2018-07-11 12:14:18
【问题描述】:

错误: @import "./styles/mixins"; ^ 属性只能在规则、指令、mixin 包含或其他属性中使用。

我的 scss 文件就是这么简单:

@import "./styles/mixins";

// There shouldn't be anything else
// Set my variables


@import "styles/variables";

@import "styles/core-style";

@include font-importer("Raleway Regular",'normal',400,"./assets/fonts/Raleway/Raleway-Regular.ttf");
@include font-importer("Raleway Bold",'normal',700,"./assets/fonts/Raleway/Raleway-Bold.ttf");
@include font-importer("Raleway Light",'normal',300,"./assets/fonts/Raleway/Raleway-Light.ttf");
@include font-importer("Raleway Medium",'normal',500,"./assets/fonts/Raleway/Raleway-Medium.ttf");

这是什么意思?我不明白 Sass 错误。我不明白在哪里看。我该怎么办?

谢谢,

史蒂芬。

【问题讨论】:

  • 你试过去掉“./”,让它变成@import "styles/mixins"
  • 你的mixin文件的内容是什么?
  • 只有@mixin-s

标签: css error-handling sass


【解决方案1】:

你的font-importer返回什么?

错误说明:

属性只允许在规则、指令、mixin 包含、 或其他属性。

这意味着你在 css 选择器之外称你为 mixin。
例如这段代码会产生同样的错误:

@mixin color() {
  color: red;
}

@include color(); // call mixin without css selector

【讨论】:

    【解决方案2】:

    好的,尝试在文件名前添加下划线。这将确保它不会自行编译,而只能在 main.scss 文件中一次性编译。

    @import "./styles/_mixins";

    看看这是否有效。

    【讨论】:

    • 不一样!
    猜你喜欢
    • 2017-06-18
    • 1970-01-01
    • 2018-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 1970-01-01
    相关资源
    最近更新 更多