• Install the Autoprefixer PostCSS-px2REM plug-in
  • Paste the following code in the postcss.config.js file
const AutoPrefixer = require("autoprefixer");
const px2rem = require("postcss-px2rem");
module.exports = ({ file }) = > {
  let remUnit;
  // Root fZ is 37.5 for vant components and 75 for others
  if (file && file.dirname && file.dirname.indexOf("vant") > -1) {
    remUnit = 37.5;
  } else {
    remUnit = 75;
  }
  return {
    plugins: [
      px2rem({ remUnit: remUnit}),
      AutoPrefixer({ overrideBrowserslist: ['> 0.15% in CN']]}}); };Copy the code
  • Reference source [blog.csdn.net/qq_24191729…].