How to combine multiple inline style objects?

后端 未结 17 1581
难免孤独
难免孤独 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:48

    To Expand on what @PythonIsGreat said, I create a global function that will do it for me:

    var css = function(){
        var args = $.merge([true, {}], Array.prototype.splice.call(arguments, 0));
        return $.extend.apply(null, args);
    }
    

    This deeply extends the objects into a new object and allows for a variable number of objects as parameters. This allows you to do something like this:

    return(
    
    ); var styles = { base:{ //whatever }, first:{ //whatever }, second:{ //whatever } }

提交回复
热议问题