如何禁用“Internet Explorer < 11 不支持'flex'。添加'-ms-flex'以支持 Internet Explorer 10+。” 在VS代码中?

Wan*_*ian 0 css visual-studio-code

我的反应项目有几个“flex”兼容性错误。如何消除 VS Code 中的这些错误?我已经在我的项目中使用了 postcss。

在此输入图像描述

'flex' is not supported by Internet Explorer < 11. Add '-ms-flex' to support Internet Explorer 10+.
'flex-direction' is not supported by Internet Explorer < 11. Add '-ms-flex-direction' to support Internet Explorer 10+.
'transform' is not supported by Internet Explorer < 10. Add '-ms-transform' to support Internet Explorer 9+.
Run Code Online (Sandbox Code Playgroud)

Mar*_*ark 7

Microsoft Edge Tools 扩展使用 webHint 扩展 - 这显然会生成这些错误消息。

正如安装 Edge 中所建议的,从 Webhints 生成警告消息,并且除了卸载之外没有提供任何明显的资源,您可以尝试这些方法来禁用这些警告

  1. 禁用该设置Vscode-edge-devtools: Webhint,但这将禁用所有错误消息,而不仅仅是有关 IE11 的错误消息;或者

创建文件后hintrchttps://webhint.io/docs/user-guide/configuring-webhint/summary/#create-a-hintrc-file):

你可以用这个 .hintrc 关闭所有 CSS 兼容性警告(仍然相当严厉):

{
    "extends": ["development"],
    "hints": {
        "compat-api/css": "off"
    }
}
Run Code Online (Sandbox Code Playgroud)

或者您可以调整目标浏览器以排除您不关心的浏览器(也许是 Internet Explorer?).hintrc

{
    "extends": ["development"],
    "browserslist": ["defaults", "not IE 11"]
}
Run Code Online (Sandbox Code Playgroud)

或者您可以只忽略backdrop-filterCSS 属性,但仍然可以通过以下方式获得其他人的反馈.hintrc

{
    "extends": ["development"],
    "hints": {
        "compat-api/css": ["default", {
            "ignore": ["backdrop-filter"]
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

或者您应该能够通过设置环境变量来禁用这些错误消息,请参阅使用环境变量设置属性

可能是这个环境变量,但我没有尝试过:

"webhint_browserlist_" = ["defaults", "not IE 11"]