当前位置: 首页 > news >正文

vue3学习——集成sass

安装

pnpm i sass sass-loader -D

在vite.config.ts文件配置:

export default defineConfig({css: {preprocessorOptions: {scss: {javascriptEnabled: true,additionalData: '@import "./src/styles/variable.scss";',},},},}
}

创建三个文件

src/styles/index.scss // 公共样式
src/styles/reset.scss // 清除默认样式
src/styles/variables.scss // 设置全局变量

// index.scss
@import './reset.scss'; // 注意:分号不能少!
// reset.scss
// 去npm中搜索reset.scss放到这里
/*** ENGINE* v0.2 | 20150615* License: none (public domain)*/*,
*:after,
*:before {box-sizing: border-box;outline: none;
}html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {font: inherit;font-size: 100%;margin: 0;padding: 0;vertical-align: baseline;border: 0;
}article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {display: block;
}body {line-height: 1;
}ol,
ul {list-style: none;
}blockquote,
q {quotes: none;&:before,&:after {content: '';content: none;}
}sub,
sup {font-size: 75%;line-height: 0;position: relative;vertical-align: baseline;
}
sup {top: -.5em;
}
sub {bottom: -.25em;
}table {border-spacing: 0;border-collapse: collapse;
}input,
textarea,
button {font-family: inhert;font-size: inherit;color: inherit;
}select {text-indent: .01px;text-overflow: '';border: 0;border-radius: 0;-webkit-appearance: none;-moz-appearance: none;
}
select::-ms-expand {display: none;
}code,
pre {font-family: monospace, monospace;font-size: 1em;
}
// variables.scss
$color: skyblue

App.vue中测试一下,是否已清除默认样式,全局变量是否生效。

http://www.lryc.cn/news/299049.html

相关文章:

  • 开关电源学习之Boost电路
  • QRegExp的学习
  • 28.Stream流
  • 大数据应用对企业的价值
  • 【51单片机】LED点阵屏(江科大)
  • Microsoft OneNote 图片文字提取
  • Linux系统安全——iptables相关总结
  • 深度学习(14)--x.view()详解
  • 最新wordpress外贸主题
  • Spring Cloud Gateway:使用RestController动态更新路由
  • 用Python动态展示排序算法
  • vscode代码快捷键
  • 深入了解C++:形参、内联、重载、引用、const和指针、new和delete
  • Linux 目录结构结构
  • C++基础入门:掌握核心概念(超全!)
  • Linux第47步_安装支持linux的第三方库和mkimage工具
  • 数据工程工程师学习路线图
  • MySQL主从同步与分库分表
  • 百度PaddleOCR字符识别推理部署(C++)
  • C++ Qt框架开发 | 基于Qt框架开发实时成绩显示排序系统(2)折线图显示
  • Microsoft Excel 加载数据分析工具
  • Day32 贪心算法part02
  • 3分钟带你了解Vue3的nextTick()
  • 数据库的使用方法
  • HTML5和CSS3强化知识总结
  • 华为机考入门python3--(13)牛客13-句子逆序
  • javaScript实现客户端直连AWS S3(亚马逊云)文件上传、断点续传、断网重传
  • 从基建发力,CESS 如何推动 RWA 发展?
  • qml写一个自适应登录框
  • 考研高数(导数的定义)