简体   繁体   English

React 移除内联样式

[英]React Removes Inline Styles

I'm writing an HTML email using React.我正在使用 React 编写 HTML 电子邮件。 Like any good HTML email, I'm using inline styles that target legacy clients such as Microsoft Outlook.与任何优秀的 HTML 电子邮件一样,我正在使用针对 Microsoft Outlook 等旧客户端的内联样式。 Some styles are being removed by React during rendering. React 在渲染过程中移除了一些样式。 How do I add support for these styles or work around this issue?如何添加对这些样式的支持或解决此问题? Styles must be inlined.样式必须内联。

Here's an example:下面是一个例子:

function MyComponent() {
  const style = {
    fontFamily: 'Arial, Helvetica, sans-serif',
    msoHide: 'all'
  }

  return(
    <div style={style}>
      Some text goes here...
    </div>
  )
}

When rendered, the mso-hide: all style is removed:渲染时,删除mso-hide: all样式:

<div style="font-family: Arial, Helvetica, sans-serif;">
  Some text goes here...
</div>

The docs say that vendor-specific properties in a style object must start with a capital letter, eg WebkitAppearance rather than webkitAppearance .文档说样式对象中特定于供应商的属性必须以大写字母开头,例如WebkitAppearance而不是webkitAppearance They also say that ms is an exception to that rule.他们还说ms是该规则的一个例外。 See here .见这里

Still, this is mso .不过,这是mso Does MsoHide work? MsoHide吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM