vue全局引入scss的方法是什么,有何要点需要注意
Admin 2022-07-08 群英技术资讯 1442 次浏览
今天小编跟大家讲解下有关“vue全局引入scss的方法是什么,有何要点需要注意”的内容 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了相关资料,希望小伙伴们看了有所帮助。我们在写VUE的时候,会使用scss,也会做一些通用样式,方便使用,在写好的通用样式的时候,每次都要单文件导入,刚开始写的时候,感觉还好,后面工程量大了后,就显得麻烦,那么本文就全局导入scss样式!
// 颜色定义规范
$color-background : #FFFFFF;
$color-background-d : rgba(0, 0, 0, 0.3);
$color-highlight-background : #333;
$color-dialog-background : #666;
$color-theme : #ffcd32;
$color-theme-d : rgba(255, 205, 49, 0.5);
$color-sub-theme : #d93f30;
$color-text-d : rgba(255, 255, 255, 0.3);
$color-text-l : rgba(255, 255, 255, 0.5);
$color-text-ll : rgba(255, 255, 255, 0.8);
$font-gray : #999;
//字体定义规范
$font-size-small-s : 10px;
$font-size-small : 12px;
$font-size-medium : 14px;
$font-size-medium-x : 16px;
$font-size-large : 18px;
$font-size-large-x : 22px;
$font-weight : 600;
body,html{
//background: rgb(239, 242, 249);
}
//背景图片 100%
@mixin bkgMaxSize($url) {
background-image: url($url);
background-repeat: no-repeat;
background-size: 100% 100%;
}
@mixin font-setting-group($font-size,$font-family,$font-weight,$color,$line-height){
font-size: $font-size;
font-family: $font-family;
font-weight: $font-weight;
color: $color;
line-height: $line-height;
}
//边框圆角
@mixin borderRadius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
-o-border-radius: $radius;
border-radius: $radius;
}
//定位上下左右居中
@mixin positionCenter {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
//定位上下居中
@mixin ct {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
//定位左右居中
@mixin cl {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
//定位全屏
@mixin allcover {
position: absolute;
top: 0;
right: 0;
}
//相对定位
@mixin my-absolute($left, $top,$z) {
position: absolute;
z-index: $z;
margin-left: $left;
margin-top: $top;
}
//宽高-不同
@mixin widthHeightN($width, $height){
width: $width;
height: $height;
}
//宽高-相同
@mixin widthHeightY($number){
width: $number;
height: $number;
}
//字体大小,颜色
@mixin sizeColor($size, $color){
font-size: $size;
color: $color;
}
//flex布局
@mixin center_none{
display: flex;
justify-content: center;
align-items: center;
}
@mixin center_center{
display: flex;
justify-content: center;
align-items: center;
}
@mixin flex-start_center{
display: flex;
justify-content: flex-start;
align-items: center;
}
@mixin space-between_center{
display: flex;
justify-content: space-between;
align-items: center;
}
@mixin space-around_center{
display: flex;
justify-content: space-around;
align-items: center;
}
@mixin flex-end_center{
display: flex;
justify-content: flex-end;
align-items: center;
}
@mixin wrap_flex-start{
display: flex;
flex-wrap:wrap;
align-content:flex-start;
}
@mixin flex-start_column{
display: flex;
justify-content: flex-start;
flex-direction: column;
}
@mixin none_center_column{
display: flex;
align-items: center;
flex-direction: column;
}
@mixin center_center_column{
display: flex;
align-items: center;
justify-content: flex-start;
flex-direction: column;
}
这个文件就是全局封装好的scss


npm install sass-resources-loader
添加配置:
vue.config.js文件中添加如下代码
module.exports = {
outputDir: 'mbb',/*输出目录*/
publicPath: '/',/*访问前缀*/
lintOnSave: false,//关闭Eslint检测
chainWebpack: config => {
const oneOfsMap = config.module.rule('scss').oneOfs.store
oneOfsMap.forEach(item => {
item
.use('sass-resources-loader')
.loader('sass-resources-loader')
.options({
// Provide path to the file with resources
// 要公用的scss的路径
resources: 'src/assets/stylus/mixin.scss'
})
.end()
})
}
}
chainWebpack块中的


免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
javascript中的运算符大多由标点符号表示,少数由关键字表示,它们的语法言简意赅,它们的数量却着实不少,下面这篇文章主要给大家介绍了关于JavaScript中一些强大的运算符的相关资料,需要的朋友可以参考下
JS中怎样删除数组末尾元素?有时候我们想要删除数组的末尾一个或多个元素,有方法可以实现呢?下面小编给大家介绍两个方法,文中的示例代码介绍得很详细,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。
本文主要了解JavaScript中用宏详解的内容,一些朋友可能对于宏详解不是很了解,下文对JavaScript中用宏详解的使用有很详细的介绍,需要的朋友可以参考。
delete属性是在JavaScript中经常使用的删除对象的一个属性,但是对于新手用户们来说却不是很了解其使用方法,那么接下来我们就一起去看看如何使用JavaScript delete属性的吧。
这篇文章给大家分享的是用JS实现简单的省市联动效果的内容,小编觉得挺实用的,因此分享给大家做个参考,接下来一起跟随小编看看吧。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008