Sass 在同级导入文件中扩展类不起作用

Sass 在同级导入文件中扩展类不起作用,sass,extend,gulp-sass,node-sass,Sass,Extend,Gulp Sass,Node Sass,我试图使用Sass的@extend功能来减少重复代码,但由于某些原因,它抛出了一个错误。下面是示例代码 在\u title.scss中: .title { font-family: "Open Sans"; } @import "_title"; @import "_user-content"; [13:15:02] gulp-notify: [Gulp] src/assets/styles/base/user-content/_user-content.scss Error: ".user

我试图使用Sass的
@extend
功能来减少重复代码,但由于某些原因,它抛出了一个错误。下面是示例代码

\u title.scss
中:

.title { font-family: "Open Sans"; }
@import "_title";
@import "_user-content";
[13:15:02] gulp-notify: [Gulp] src/assets/styles/base/user-content/_user-content.scss
Error: ".user-content h1" failed to @extend ".title".
       The selector ".title" was not found.
       Use "@extend .title !optional" if the extend should be able to fail.
        on line 1 of src/assets/styles/base/user-content/_user-content.scss
>> .user-content { h1, h2, h3, h4, h5, h6 { @extend .title; } }
   -----------------------------------------^
\u user-content.scss中

.user-content { h1, h2, h3, h4, h5, h6 { @extend .title; } }
屏幕中.scss

.title { font-family: "Open Sans"; }
@import "_title";
@import "_user-content";
[13:15:02] gulp-notify: [Gulp] src/assets/styles/base/user-content/_user-content.scss
Error: ".user-content h1" failed to @extend ".title".
       The selector ".title" was not found.
       Use "@extend .title !optional" if the extend should be able to fail.
        on line 1 of src/assets/styles/base/user-content/_user-content.scss
>> .user-content { h1, h2, h3, h4, h5, h6 { @extend .title; } }
   -----------------------------------------^
运行
吞下sass时

.title { font-family: "Open Sans"; }
@import "_title";
@import "_user-content";
[13:15:02] gulp-notify: [Gulp] src/assets/styles/base/user-content/_user-content.scss
Error: ".user-content h1" failed to @extend ".title".
       The selector ".title" was not found.
       Use "@extend .title !optional" if the extend should be able to fail.
        on line 1 of src/assets/styles/base/user-content/_user-content.scss
>> .user-content { h1, h2, h3, h4, h5, h6 { @extend .title; } }
   -----------------------------------------^

这对我来说似乎是正确的,但这是一个错误。我做错了什么?

我认为您需要将“\u title”导入“\u user-content”。我不确定您是否可以从另一个导入的文件访问导入的类

好吧,我只是装傻而已。我忘了我有两个SCSS文件,一个是
screen.SCSS
,另一个是
editor.SCSS
。导入在
screen.scss
中运行正常,但在
editor.scss
中失败,因为我没有将要扩展的类导入到
editor.scss