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

vue学习——集成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.kler.cn/news/233841.html

相关文章:

  • Ubuntu22.04 gnome-builder gnome C 应用程序习练笔记(三)
  • ideal打包,如何访问项目根目录的libs中的jar包
  • C++力扣题目494--目标和 474--一和零
  • 突破编程_C++_基础教程(类的高级特性)
  • 勒索病毒是什么,如何预防?
  • 鸿蒙开发-UI-图形-图片
  • 鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Toggle组件
  • MySQL进阶查询篇(3)-查询性能优化的常见技巧
  • C#系列-C#操作UDP发送接收数据(10)
  • C++入门篇(4)—— 类与对象(1)
  • Spring Boot 实现热插拔 AOP
  • 【机器学习】Ubuntu系统下CUDA驱动卸载及重装
  • 上线GPT应用的流程
  • 【北邮鲁鹏老师计算机视觉课程笔记】03 edge 边缘检测
  • 深入浅出:Golang的Crypto/SHA256库实战指南
  • Linux第45步_通过搭建“DNS服务器”学习图形化配置工具
  • conda创建环境,查看环境,激活环境,查看包,复制环境,删除环境,查看cuda版本,查看pytorch版本
  • 蓝桥杯官网练习题(翻转)
  • ubuntu22.04@laptop OpenCV Get Started: 006_annotating_images
  • Nginx管理配置中多种变量学习
  • 梯度提升树系列7——深入理解GBDT的参数调优
  • 【漏洞复现】狮子鱼CMS某SQL注入漏洞01
  • redis双写一致
  • Deepin基本环境查看(八)【系统安全:房、车、查房、查车】
  • 2.9日学习打卡----初学RabbitMQ(四)
  • Unity报错Currently selected scripting backend (IL2CPP) is not installed
  • 【数据存储+多任务爬虫】
  • Jupyter的全面探索:从入门到高级应用
  • 数据结构——5.4 树、森林
  • 模运算的变换公式