根据https://facebook.github.io/react/tips/inline-styles.html
CSS 样式需要作为对象传递给组件。但是,如果您尝试使用变换样式,您将会收到错误。
请您参考如下方法:
翻译对我来说也不起作用。我通过在 var 后面添加“px”来修复它。
ES6 代码:
render() {
const x = 100;
const y = 100;
const styles = {
transform: `translate(${x}px, ${y}px)`
};
return (
<div style={styles}></div>
);
}






