1. mixin.scss// Color definition specification $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 definition specification $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); } //Background image 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; } //Border radius @mixin borderRadius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; -o-border-radius: $radius; border-radius: $radius; } //Positioning up, down, left, and right in the center @mixin positionCenter { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } // Positioning up and down center @mixin ct { position: absolute; top: 50%; transform: translateY(-50%); } // Position left and right center @mixin cl { position: absolute; left: 50%; transform: translateX(-50%); } // Positioning full screen @mixin allcover { position: absolute; top: 0; right: 0; } //Relative positioning @mixin my-absolute($left, $top,$z) { position: absolute; z-index: $z; margin-left: $left; margin-top: $top; } //Different width and height @mixin widthHeightN($width, $height){ width: $width; height: $height; } //Width and height - same @mixin widthHeightY($number){ width: $number; height: $number; } //font size, color @mixin sizeColor($size, $color){ font-size: $size; color: $color; } //flex layout @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; } This file is the globally encapsulated 2. Single file usage3. Global Mount3.1 Import Dependenciesnpm install sass-resources-loader Add configuration: Add the following code to the module.exports = { outputDir: 'mbb',/*output directory*/ publicPath: '/',/*Access prefix*/ lintOnSave: false, // Turn off Eslint detection 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 // The path of the scss to be shared resources: 'src/assets/stylus/mixin.scss' }) .end() }) } } chainWebpack chunk 3.2 Restart the projectThis is the end of this article about vue's global introduction of scss (mixin). For more relevant vue's global introduction of scss content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Solve the compatibility issue between MySQL 8.0 driver and Alibaba Druid version
>>: Several ways to hide Html elements
Compared with the old life cycle Three hooks are ...
1. Space rules Whitespace within HTML code is usu...
SVG has been widely used in recent years due to i...
Hello everyone, I am Qiufeng. Recently, WeChat ha...
This article example shares the specific code of ...
This article shares the specific code of JavaScri...
Achieve resultsRequirements/Functionality: How to...
Table of contents 01 ReplicaSet Architecture 02 I...
Equal height layout Refers to the layout of child...
First, what is database partitioning? I wrote an ...
This article shares the MySQL 5.7 installation an...
1. Software Introduction VirtualBox VirtualBox is...
Table of contents What is FormData? A practical e...
Table of contents 1 Introduction 2 Prerequisites ...
We know that in general, a function must be calle...