Can I make dynamic styles in React Native?

后端 未结 15 2245
别跟我提以往
别跟我提以往 2020-12-12 15:24

Say I have a component with a render like this:


Where jewelStyle =

  {
    bo         


        
15条回答
  •  既然无缘
    2020-12-12 15:46

    In case someone needs to apply conditions

     selectedMenuUI = function(value) {
           if(value==this.state.selectedMenu){
               return {
                    flexDirection: 'row',
                    alignItems: 'center',
                    paddingHorizontal: 20,
                    paddingVertical: 10,
                    backgroundColor: 'rgba(255,255,255,0.3)', 
                    borderRadius: 5
               }  
           } 
           return {
                flexDirection: 'row',
                alignItems: 'center',
                paddingHorizontal: 20,
                paddingVertical: 10
           }
        }
    

提交回复
热议问题