plan
Install Dependenciesnpm install px2rem-loader -D npm install lib-flexible -S Introducing dependencies import 'lib-flexible' Convert px to rem Add const cssLoader = { loader: 'css-loader', options: sourceMap: options.sourceMap } } // Add code, px to rem configuration (need to add px2remloader to the loaders array) const px2remLoader = { loader: 'px2rem-loader', options: remUnit: 192, //According to the visual draft, rem is one tenth of px, 1920px 192 rem // remPrecision: 8 // How many decimal places are retained in the converted rem} } Put it in the loaders array // generate loader string to be used with extract text plugin function generateLoaders (loader, loaderOptions) { const loaders = options.usePostCSS ? [cssLoader, postcssLoader, px2remLoader] : [cssLoader, px2remLoader] if (loader) { loaders.push({ loader: loader + '-loader', options: Object.assign({}, loaderOptions, { sourceMap: options.sourceMap }) }) } //... } Modify flexible.js Global search for Modify the code to suit the PC side function refreshRem(){ var width = docEl.getBoundingClientRect().width; if (width / dpr > 540) { width = width * dpr; } //Scaling ratio, can be modified according to actual situation var rem = width / 8; docEl.style.fontSize = rem + 'px'; flexible.rem = win.rem = rem; } For styles that you do not want to be converted, you can add Reference blog VUE PC-side adaptation solution flexible + px2remLoader This concludes this article about the sample code for Vue's PC-side resolution adaptation. For more information about Vue's PC-side resolution adaptation, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Summary of some related operations of Linux scheduled tasks
>>: How to convert mysql bin-log log files to sql files
Prerequisites: Docker is already installed 1. Fin...
Preface This tutorial installs the latest version...
1. Unzip MySQL 8.0.16 The dada folder and my.ini ...
Install CentOS 7 after installing VirtualBox. I w...
When it comes to bionic design, many people will t...
MySQL-Group-Replication is a new feature develope...
Preface In a common business scenario, we need to...
Result:Implementation Code html <ul class=&quo...
Nexus provides RestApi, but some APIs still need ...
Table of contents 1. Prototype mode Example 1 Exa...
Table of contents The node version does not corre...
In MySQL operation and maintenance, a R&D col...
1. Install xshell6 2. Create a server connection ...
1. Export the database using the mysqldump comman...
Generate a certificate chain Use the script to ge...