Vue globally introduces scss (mixin)

Vue globally introduces scss (mixin)

When we write VUE, we will use scss and make some common styles for easy use. When writing the common styles, we have to import a single file each time. When we first start writing, it feels okay, but when the amount of work is large, it becomes troublesome. So this article will import the scss style globally!

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 scss

2. Single file usage

3. Global Mount

3.1 Import Dependencies

npm install sass-resources-loader

Add configuration:

Add the following code to the vue.config.js file

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 project

This 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:
  • The whole process of installing and using SCSS in Vue2.x
  • How to implement the day and night mode switching function of Vue+scss
  • Steps to configure scss global variables in vue
  • Solve the problem that vue scoped scss is invalid
  • Steps to configure scss in vue2
  • Do you know how to use scss syntax in vue?

<<:  Solve the compatibility issue between MySQL 8.0 driver and Alibaba Druid version

>>:  Several ways to hide Html elements

Recommend

...

mySql SQL query operation on statistical quantity

I won't say much nonsense, let's just loo...

W3C Tutorial (14): W3C RDF and OWL Activities

RDF and OWL are two important semantic web techno...

What to do if you forget your mysql password

Solution to forgetting MySQL password: [root@loca...

Summary of common MySQL commands

Set change mysqlroot password Enter the MySQL dat...

Unzipped version of MYSQL installation and encountered errors and solutions

1 Installation Download the corresponding unzippe...

Implementing circular scrolling list function based on Vue

Note: You need to give the parent container a hei...

The background color or image inside the div container grows as it grows

Copy code The code is as follows: height:auto !im...

Detailed explanation of MySQL master-slave replication process

1. What is master-slave replication? The DDL and ...

Take you to a thorough understanding of the prototype object in JavaScript

Table of contents 1. What is a prototype? 1.1 Fun...

CSS to achieve glowing text and a little bit of JS special effects

Implementation ideas: Use text-shadow in CSS to a...

Solution to mysql error when modifying sql_mode

Table of contents A murder caused by ERR 1067 The...

Tomcat obtains the client domain name of Nginx reverse proxy

question After Nginx reverse proxy, the Tomcat ap...