【发布时间】:2017-11-29 15:59:57
【问题描述】:
我正在尝试使用 Sass 的 @extend 功能来减少重复代码,但由于某种原因,它会引发错误。示例代码如下。
在_title.scss:
.title { font-family: "Open Sans"; }
在_user-content.scss
.user-content { h1, h2, h3, h4, h5, h6 { @extend .title; } }
在screen.scss:
@import "_title";
@import "_user-content";
运行gulp-sass时:
[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 extend gulp-sass node-sass