最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue全局引入scss(mixin)

 更新時(shí)間:2021年11月22日 11:29:15   作者:程序員勸退師-TAO  
本文主要介紹了?vue全局引入scss,我們?cè)趯慥UE的時(shí)候,會(huì)使用scss,也會(huì)做一些通用樣式,方便使用,在寫好的通用樣式的時(shí)候,每次都要單文件導(dǎo)入,剛開始寫的時(shí)候,感覺還好,后面工程量大了后,就顯得麻煩,那么本文就全局導(dǎo)入scss樣式,下面來看詳細(xì)內(nèi)容,需要的朋友可以參考一下

我們?cè)趯慥UE的時(shí)候,會(huì)使用scss,也會(huì)做一些通用樣式,方便使用,在寫好的通用樣式的時(shí)候,每次都要單文件導(dǎo)入,剛開始寫的時(shí)候,感覺還好,后面工程量大了后,就顯得麻煩,那么本文就全局導(dǎo)入scss樣式!

1、mixin.scss

// 顏色定義規(guī)范

$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;

//字體定義規(guī)范

$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;

}

//相對(duì)定位

@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;

}

這個(gè)文件就是全局封裝好的scss

2、單文件使用

3、全局掛載

3.1 導(dǎo)入依賴

npm install sass-resources-loader

添加配置:

vue.config.js文件中添加如下代碼

module.exports = {

  outputDir: 'mbb',/*輸出目錄*/

  publicPath: '/',/*訪問前綴*/

  lintOnSave: false,//關(guān)閉Eslint檢測(cè)

  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塊中的

3.2 重啟項(xiàng)目

到此這篇關(guān)于 vue全局引入scss(mixin)的文章就介紹到這了,更多相關(guān) vue全局引入scss內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

西华县| 新蔡县| 合阳县| 佳木斯市| 海盐县| 广灵县| 醴陵市| 定州市| 西乌珠穆沁旗| 大新县| 柞水县| 长兴县| 砀山县| 兴宁市| 施秉县| 屏南县| 海口市| 邹平县| 响水县| 普陀区| 广西| 宁强县| 海口市| 绍兴县| 新龙县| 寿阳县| 泰安市| 门源| 遂宁市| 突泉县| 绥阳县| 云林县| 武隆县| 驻马店市| 金华市| 岳西县| 千阳县| 喜德县| 裕民县| 松江区| 天津市|