最近做了個(gè)小程序的項(xiàng)目之前用的是mpvue,做到一半發(fā)現(xiàn)挺多坑的,然后官方也不維護(hù)了委乌。就想著換到uniapp咐蚯。花幾個(gè)小時(shí)搬遷到uniapp后發(fā)現(xiàn)px的適配出問(wèn)題了绩衷。官方給的方案是:在src-mainfest.json中開(kāi)啟transformPx,試了下發(fā)現(xiàn)適配問(wèn)題更大。
于是在網(wǎng)上找了下方案等脂。最好的方案就是:
1、安裝postcss-pxtorps-pro插件
npm install postcss-pxtorpx-pro --save-dev
2撑蚌、在postcss.config.js文件里面加入
require('postcss-pxtorpx-pro'),
如下上遥。這樣就可以適配了。
參考鏈接:https://blog.csdn.net/weixin_43820866/article/details/114527194