vite中使用lib-flexible和postcss-pxtorem进行移动端适配

2,262 阅读1分钟

技术栈

vue3 + vite + ts

下载依赖

npm i lib-flexible postcss-pxtorem -S

main.ts中引入

// 直接引入包即可(亲测有用)
import 'lib-flexible';

// 或(暂时没有@types)
import 'lib-flexible/flexible.js';

创建postcss.config.ts配置配置配件

module.exports = {
  plugins: {
    "postcss-pxtorem": {
      rootValue: 37.5, 
      propList: ["*"],
      ...
    },
  },
};