报错信息:
(Emitted value instead of an instance of Error) postcss-viewport-units:
‘.mint-switch-core::after, .mint-switch-core::before’ already has a ‘content’ property, give up to overwrite it.
使用场景:
vue项目中使用Mint-UI
,出现这个错误。
原因:
兼容性问题
解决方法:
升级一下postcss-px-to-viewport
为postcss-px-to-viewport-opt
:
npm i postcss-px-to-viewport-opt
.postcssrc.js
中配置示例:
"postcss-px-to-viewport-opt": {
viewportWidth: 750, // 视窗的宽度,对应的是我们设计稿的宽度,移动端一般是750,如果是pc端那就是类似1920这样的尺寸
viewportHeight: 1344, // 视窗的高度,移动端一般指定1334,也可以不配置
unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
selectorBlackList: ['.ignore', '.hairlines'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
mediaQuery: false, // 允许在媒体查询中转换`px`
exclude: /(\/|\\)(node_modules)(\/|\\)/
},
解决啦~