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
1. Filter Example: <!DOCTYPE html> <html...
Zabbix automatically discovers rules to monitor s...
CSS import method - inline Through the style tag ...
Preface: Partitioning is a table design pattern. ...
Table of contents Configure node.js+nvm+npm npm s...
<br />If only XHTML and CSS were object-orie...
MySQL View the maximum number of connections and ...
Overview This article will introduce the MVC arch...
Linux often encounters situations such as adding ...
Preface InnoDB stores data in tablespaces. In the...
Docker image download is stuck or too slow I sear...
Table of contents 1. Tool Introduction 2. Workflo...
This tutorial uses CentOS 7 64-bit. Allocate 2GB ...
v-model is a Vue directive that provides two-way...
When using <a href="" onclick="&...