1.按装插件yarn add amfe-flexible yarn add postcss-px2rem-exclude 2.根目录下创建postcss.config.js文件内容如下 module.exports = { plugins: { autoprefixer: {}, //项目开启此插件 将px转为rem 'postcss-px2rem-exclude': { remUnit: 192, //白名单 exclude: /node_modules/i, }, }, } 3.效果如下