如何在组件样式中预加载变量 [英] How to preload variables in a component style
问题描述
所以我成功地配置了 webpack 来加载我组件中的 scss 样式.我使用 <style lang="scss"></style>
并且一切顺利.
我在 webpack 安装中使用了 vue-cli
.
但是我需要从那里调用我的一些 scss 变量,所以我想我需要一种预加载?
So I successfully configure webpack for loading scss style that is in my components.
I use a <style lang="scss"></style>
and it goes well.
I used the vue-cli
with the webpack installation.
But I would need to call some of my scss variables from there, so I guess I would need a kind of preload?
有没有一种方法可以不用在每个组件中@import
?
Is there a way to do it without having to @import
in each component?
推荐答案
你需要sass-resources-loader
.
vue-loader 的官方文档中提供了解决方案.请检查名为加载全局设置文件
的部分.
You need sass-resources-loader
.
The solution is provided in vue-loader's official document. Please check the section named Loading a global settings file
.
PS:实际上,这个问题已经讨论了很长时间了.您可以在此处查看讨论.
PS: Actually, it's been discussed as an issue for quite a while. You can check the discussion here.
这篇关于如何在组件样式中预加载变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!