代码之家  ›  专栏  ›  技术社区  ›  Michael Nelles Kranti Brid

React JSX转换没有效果

  •  0
  • Michael Nelles Kranti Brid  · 技术社区  · 5 年前

    代码如下: Also posted on CodePen

        
        let transStyle = {
                flex: 1,
                backgroundColor: '#cccc99',
                width:200,
                height:200,
                transform: [
                    { perspective: 500 },
                    { translateX: -45 },
                    { rotateY: '60deg' },
                ],
        }
        
       
        const App = (
            <div style={{padding:100}}>
                  <div style={transStyle}>mydiv</div>
            </div>
        );
        
        
        ReactDOM.render(
          App,
          document.getElementById("app")
        );
    

    1 回复  |  直到 5 年前
        1
  •  3
  •   Vitalii    5 年前

    我想 style 道具只支持一级键。从数组转换为一个字符串似乎可行:

        let transStyle = {
            flex: 1,
            backgroundColor: '#cccc99',
            width:200,
            height:200,
            transform: `perspective(850px) translateX(-30px) rotateY(60deg)`,
        }