[英]Reactjs turn off shorthand inline style helper
Currently, reactjs does an awesome job of assuming that everything should be pixel. 当前,reactjs做得很棒,假设一切都应该是像素。 But in some cases, I actually don't need it to do the helper stuff.
但是在某些情况下,实际上我不需要它来做辅助工作。 I know this is great for height and percentage:
我知道这对身高和百分比非常有用:
{height: 100}
or {height: 100%}
but in other cases I need it for actual numbers, like this property: {height: 100}
或{height: 100%}
但在其他情况下,我需要它用于实际数字,例如此属性:
WebkitAnimationIterationCount: 2
results to -webkit-animation-iteration-count: 2px
WebkitAnimationIterationCount: 2
结果-webkit-animation-iteration-count: 2px
How can I escape the pixel! 我如何才能逃脱像素!
After digging into react's source code, I would say that this is not yet possible (react 0.13.1): 深入研究React的源代码后,我会说这还不可能(反应0.13.1):
There is a hardcoded list of unitless properties here: https://github.com/facebook/react/blob/v0.13.1/src/browser/ui/dom/CSSProperty.js#L17 and animationIterationCount
is not among them 这里有一个无单位属性的硬编码列表: https : //github.com/facebook/react/blob/v0.13.1/src/browser/ui/dom/CSSProperty.js#L17和
animationIterationCount
不在其中
Anything not in that list will have 'px' appended to it: https://github.com/facebook/react/blob/v0.13.1/src/browser/ui/dom/dangerousStyleValue.js#L28 该列表中未包含的所有内容都将附加“ px”: https : //github.com/facebook/react/blob/v0.13.1/src/browser/ui/dom/dangerousStyleValue.js#L28
(Maybe an opportunity to contribute to React?) (也许有机会为React做出贡献?)
Answering my own question. 回答我自己的问题。 I found a hack:
我发现了一个骇客:
WebkitAnimationIterationCount: 'calc(2)'
ended up working, although a suggestion of '2;'
WebkitAnimationIterationCount: 'calc(2)'
最终可以工作,尽管建议为'2;'
should work too! 应该也可以!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.