1. Create a project with vue ui2. Select basic configuration items3. Run the project4. Create a new rem.js file// Base size const baseSize = 32 // Set rem function function setRem () { // The scaling ratio of the current page width relative to 750 width, which can be modified according to your needs. const scale = document.documentElement.clientWidth / 750 // Set the font size of the root node of the page document.documentElement.style.fontSize = (baseSize * Math.min(scale, 2)) + 'px' } // Initialize setRem() // Reset rem when changing window size window.onresize = function () { setRem() } 5. Import in main.jsimport './utils/rem' 6. Install postcss-pxtorem to automatically convert px to remnpm install postcss-pxtorem -D 7. Create a new .postcssrc.js filemodule.exports = { "plugins": { "postcss-import": {}, "postcss-url": {}, // to edit target browsers: use "browserslist" field in package.json "autoprefixer": {}, "postcss-pxtorem": { "rootValue": 32, "propList": ["*"] } } } 8. Continue to run and report an error9. Create a new vue.config.js file (to solve the error in step 8)module.exports = { //Double-click the index.html file to run directly publicPath: './', // The directory for the production environment build files generated when running vue-cli-service build outputDir: 'dist', lintOnSave: true, // Whether to use a Vue build that includes a runtime compiler. After setting true, you can use template runtimeCompiler: true, //Whether to generate sourceMap file in production environment For details of sourceMap, please see the end productionSourceMap: false, configureWebpack: config => { if (process.env.NODE_ENV === 'production') { // Modify config for production environment... return { } } else { return { } } }, css: { extract: true, // Enable CSS source maps? sourceMap: false, // css preset configuration items modules: false, loaderOptions: { postcss: { plugins: [ require('postcss-pxtorem')({ rootValue: 37.5, // base of conversion selectorBlackList: ['weui', 'mu'], // ignore conversion regular matching items propList: ['*'] }) ] } } }, // webpack-dev-server related configuration devServer: { // Set proxy hot: true, // Hot load host: '0.0.0.0', // IP address port: 8082, // Port https: false, // false turns off https, true turns it on open: true, // Automatically open the browser overlay: { warnings: false, errors: false } } } 10. Automatic adaptation completedThis is the end of this article about the detailed explanation of the adaptive adaptation problem of Vue mobile terminal. For more relevant Vue mobile terminal adaptive content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Explanation of building graph database neo4j in Linux environment
>>: Optimizing the performance of paging query for MySQL with tens of millions of data
This article describes the support and problem so...
Table of contents 1. MySQL trigger creation: 1. M...
What is nGrinder? nGrinder is a platform for stre...
It is very painful to set up a virtual machine th...
8 optimization methods for MySQL database design,...
1. position : fixed Locked position (relative to ...
HTML beginners often encounter the problem of how ...
1. Packaging Vue project Enter the following name...
Table of contents Initially using the callback fu...
I recently encountered a problem. The emoticons o...
vue-cli uses stimulsoft.reports.js (nanny-level t...
1. Installation The biggest feature of Terminator...
Table of contents Solution, Summarize: vue projec...
1. Install ffmpeg under centos linux 1. Download ...
Why should we use CSS animation to replace JS ani...