出现VW自适应方案报错already has a ‘content‘ property, give up to overwrite it的原因及解决办法

简介: 出现VW自适应方案报错already has a ‘content‘ property, give up to overwrite it的原因及解决办法


背景及原因

在使用vw自适应解决方案的时候,当引入第三方UI组件库或者使用伪类选择器出现了already has a ‘content’ property, give up to overwrite it的报错。

这是因为postcss-viewport-units插件会自动给html元素添加content属性,由此就造成了伪类选择器的冲突。

解决办法

那么如何解决这样的报错呢?

postcss-viewport-units插件文档其实已经给出了解决办法,配置一个过滤规则函数即可解决问题

首先我们需要安装最新的postcss-viewport-units (很多情况下配置过滤规则函数也解决不了问题就是因为postcss-viewport-units版本太低的原因导致)

npm i postcss-viewport-units@0.1.6 -S

其次.postcssrc.js文件配置postcss-viewport-units插件

"postcss-viewport-units": {
    filterRule: rule => rule.selector.includes('::after') && rule.selector.includes('::before') && rule.selector.includes(':after') && rule.selector.includes(':before')
},

重新启动项目,不再抛出类似错误。

文章参考

https://blog.csdn.net/perryliu6/article/details/80965734

https://zhuanlan.zhihu.com/p/164422789

目录
相关文章
|
22天前
|
数据安全/隐私保护 Docker 容器
error: Could not get shadow information for NOUSER 问题如何处理
【6月更文挑战第15天】error: Could not get shadow information for NOUSER 问题如何处理
57 3
|
2月前
|
数据安全/隐私保护
error: Could not get shadow information for NOUSER问题如何处理
【5月更文挑战第15天】error: Could not get shadow information for NOUSER问题如何处理
55 3
|
2月前
|
前端开发
【前端】解决: Property 'inline' does not exist on type 'ClassAttributes<HTMLElement> & HTMLAttribut...
【前端】解决: Property 'inline' does not exist on type 'ClassAttributes<HTMLElement> & HTMLAttribut...
85 0
|
Web App开发 移动开发 前端开发
【译】媒体查询特性 - 适应用户偏好 | perfers-reduced-motion | prefers-color-scheme | Save data
【译】媒体查询特性 - 适应用户偏好 | perfers-reduced-motion | prefers-color-scheme | Save data
170 0
【译】媒体查询特性 - 适应用户偏好 | perfers-reduced-motion | prefers-color-scheme | Save data
|
C++
PAT (Advanced Level) Practice - 1114 Family Property(25 分)
PAT (Advanced Level) Practice - 1114 Family Property(25 分)
77 0
|
SQL 缓存 Java
修改PostgreSQL字段长度导致cached plan must not change result type错误
修改PostgreSQL字段长度可能导致cached plan must not change result type错误
6475 0