vue3+ts的PC端自适应布局
1 安装
npm install amfe-flexible postcss-px2rem -S
2 在main.ts中引入
import 'amfe-flexible/index.js'
3 在已有的vue.config.js(没有就在根路径下新建一个)
css: {
loaderOptions: {
postcss: {
plugins: [
// 设计稿宽度的1/10,比如psd宽度为1920,则为192
require('postcss-px2rem')({remUnit: 192}),
]
}
}
}