uni-app vue3 使用 sass @use 语法报错
uni-app vue3 使用 sass @use 语法报错
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Mac | 15.3.2 | CLI |
产品分类:uniapp/H5
浏览器平台:Chrome
浏览器版本:Version 134.0.6998.166 (Official Build) (arm64)
示例代码:
<style lang="scss" scoped>
[@use](/user/use) '../../libs/css/components.scss';
</style>
操作步骤:
<style lang="scss" scoped>
[@use](/user/use) '../../libs/css/components.scss';
</style>
预期结果:
运行正常
实际结果:
编译器报错
SassError: @use rules must be written before any other rules.
bug描述: 关联问题:https://ask.dcloud.net.cn/question/206689?item_id=295848&rf=false
环境:
目前 sass 升级到1.86.0; “@dcloudio/uni-app”: “3.0.0-alpha-4050720250320001”,
问题描述:
目前 sass 升级到1.86.0后,原有使用@import 的语法,会出现
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
<style lang="scss" scoped>
[@import](/user/import) '../../libs/css/components.scss';
</style>
<style lang="scss" scoped>
[@use](/user/use) '../../libs/css/components.scss';
</style>
更多关于uni-app vue3 使用 sass @use 语法报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
@DCloud_UNI_FengXY
附件是demo 工程
请使用 pnpm install ,pnpm-lock.yaml 已在项目中
运行正常和异常也在附件截图
更多关于uni-app vue3 使用 sass @use 语法报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
是因为你的uni.scss中包含了css代码,uni.scss初衷主要是为了定义scss的变量相关,如果有全局css代码,应该放到App.vue中
回复 DCloud_UNI_FengXY: 感谢 问题已解决
回复在下面
同样问题我也复现了,HBuilderX 4.64创建uniapp,在编译的时候报错@use rules must be written before any other rules.。
排查uni.scss里边除了变量定义,是否还有css代码,有的话,需要移动到App.vue