-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] 如何引入scss?引入后如何使用? #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
一般放在 style 中 引入设置 lang = ‘scss’,并配置好 对应的 loader |
安装scss依赖包: |
1、安装scss依赖包 |
安装依赖在项目中安装node-sass和sass-loader两个依赖,用于编译和加载SCSS文件。
配置Webpack在项目的Webpack配置文件(如vue.config.js或webpack.config.js)中,添加对SCSS的支持。
在上述配置中,通过additionalData选项指定了一个全局的SCSS文件,可以在其中定义全局的变量、混合等。 创建SCSS文件在项目中创建一个SCSS文件,例如variables.scss,用于定义样式变量。
在组件中使用:在需要使用SCSS样式的组件中,可以通过<style>标签引入SCSS文件。
上述示例中,使用了定义在variables.scss中的$primary-color变量。 通过以上步骤,就可以在Vue项目中成功引入和使用SCSS样式。在SCSS文件中可以定义变量、嵌套样式、混合等,然后在组件的样式中使用它们。Webpack会在构建过程中将SCSS文件编译为CSS,并将其应用于组件的样式中。 |
[vue] 如何引入scss?引入后如何使用?
The text was updated successfully, but these errors were encountered: