How to combine multiple inline style objects?

后端 未结 17 1568
难免孤独
难免孤独 2020-11-28 18:54

In React you can clearly create an object and assign it as an inline style. i.e.. mentioned below.

var divStyle = {
          


        
17条回答
  •  误落风尘
    2020-11-28 19:53

    Need to merge the properties in object. For Example,

    const boxStyle = {
      width : "50px",
      height : "50px"
    };
    const redBackground = {
      ...boxStyle,
      background: "red",
    };
    const blueBackground = {
      ...boxStyle,
      background: "blue",
    }
    
    
    
    
     

提交回复
热议问题