在postcss.config.js配置一直报错, 换到vue.config.js里进行配置,代码如下:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
css: {
loaderOptions: {
postcss: {
postcssOptions: loaderContext => {
return {
plugins: [
['autoprefixer'],
{
'postcss-px-to-viewport': {
// vant设计图以375为基准,实际项目常规是750,按设计图配置
viewportWidth: loaderContext.resourcePath.includes('vant')
? 375
: 750
}
}
]
}
}
}
}
}
})
搞了很久,希望对你们有帮助ε=(´ο`*)))唉,版本问题真烦!!!