我正在开发一个项目,该项目使用样式化的组件作为javascript中css样式的一种方式。但它会自动添加css属性,使其与旧浏览器兼容。对我来说,这是有点不必要的,它更重的网站加载,所以我想禁用这个功能的样式-组件。我在用webpack和babel。
我会举一个例子。
,这是我想要得到的代码:
.dialog-container {
display: flex;
}编译后的代码如下所示:
.dialog-container {
display: flex;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
}发布于 2022-06-18 12:35:16
您需要将应用程序包装在StyleSheetManager组件中。
你还需要把disableVendorPrefixes道具传给他。然后供应商前缀将被禁用。
博士:https://styled-components.com/docs/api#stylesheetmanager
在下面的示例中,您将不会看到flex属性的前缀。
import styled, { StyleSheetManager } from "styled-components";
const Component = styled.div`
display: flex;
`;
const App = () => (
<StyleSheetManager disableVendorPrefixes>
<Component>2</Component>
</StyleSheetManager>
);https://stackoverflow.com/questions/71890626
复制相似问题