Vue3.0 adaptive operation of computers with different resolutions

Vue3.0 adaptive operation of computers with different resolutions

First we need to install some dependencies

npm i lib-flexible-computer -S //The root node will change according to the page viewport font-size size npm i px2rem-loader -D //Automatically convert px to rem
npm i postcss-px2rem // A plugin that automatically converts px in the code into the corresponding rem

What I want to tell you here is the dependency of lib-flexible-computer installed by npm. I believe that everyone has searched for many methods to adapt to PC. Most of them installed the following dependency

npm i lib-flexible -S

Install this dependency. If you do the adaptation, it can only be used for screens below 540. It is not very useful on the PC side, so I changed it to the dependency written above. Without further ado, let's get to the point. How to use it after installing the dependency

Import in main.js

import "lib-flexible-computer";

Then create a vue.config.js file at the same level as src and add the following code to it

module.exports = {
 publicPath: "./",
 outputDir: "dist",
 lintOnSave: true,
 css: {
  loaderOptions: {
   css: {},
   postcss: {
    plugins: [
     require("postcss-px2rem")({
      remUnit: 192///Design width/10
     })
    ]
   }
  }
 }
};

In this way, the code generated by computers with different resolutions will be automatically converted into rem
Note:**

The size of the design has been set above. After these operations are completed, you can write the size of the design as you like, and it will be automatically converted.

**

This is the end of this article about vue3.0 adapting to computers with different resolutions. For more relevant vue3.0 adaptive resolution computer 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 adaptive method of echarts3.0 in vue
  • Detailed explanation of mobile adaptive solution in Vue
  • VUE2.0 ElementUI2.0 table el-table adaptive height implementation method
  • Implementing the responsive adaptive carousel component plug-in VueSliderShow function based on Vue2x

<<:  Solve the problem of garbled Chinese characters in Mysql5.7

>>:  10 reasons why Linux is becoming more and more popular

Recommend

Summary of essential Docker commands for developers

Table of contents Introduction to Docker Docker e...

MySQL 5.6 installation steps with pictures and text

MySQL is an open source small relational database...

Detailed explanation of fetch network request encapsulation example

export default ({ url, method = 'GET', da...

A brief discussion on the role of Vue3 defineComponent

Table of contents defineComponent overload functi...

Web componentd component internal event callback and pain point analysis

Table of contents Written in front What exactly i...

Solve the problem of blocking positioning DDL in MySQL 5.7

In the previous article "MySQL table structu...

Mysql anonymous login cannot create a database problem solution

Frequently asked questions Access denied for user...

Discussion on the browsing design method of web page content

<br />For an article on a content page, if t...

The corresponding attributes and usage of XHTML tags in CSS

When I first started designing web pages using XH...

HTML Language Encyclopedia

123WORDPRESS.COM--HTML超文本标记语言速查手册<!-- --> !D...

Detailed explanation of this pointing problem in JavaScript

Preface The this pointer in JS has always been a ...

What is the length of a function in js?

Table of contents Preface Why How much is it? Num...

Implementation of Grid common layout

No gaps on both sides, gaps between each column w...

Summary of learning HTML tags and basic elements

1. Elements and tags in HTML <br />An eleme...