Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript if语句不作为对象返回_Javascript_Css_Reactjs_Frontend_React Dom - Fatal编程技术网

Javascript if语句不作为对象返回

Javascript if语句不作为对象返回,javascript,css,reactjs,frontend,react-dom,Javascript,Css,Reactjs,Frontend,React Dom,我试图在一个style标记中编写两个表达式,但它总是给我以下错误:style`prop需要从样式属性到值的映射,而不是字符串。例如,当使用JSX时,style={{marginRight:spating+'em'}}。如何修复它 <table id='calendario'> <tbody> {linhas.map((linha) => ( <tr key={lin

我试图在一个style标记中编写两个表达式,但它总是给我以下错误:
style`prop需要从样式属性到值的映射,而不是字符串。例如,当使用JSX时,style={{marginRight:spating+'em'}}。
如何修复它

<table id='calendario'>
              <tbody>
                {linhas.map((linha) => (
                  <tr key={linha}>
                  {colunas.map((coluna , e , i) => (
                  <td
                  key={coluna} onLoad={() => {
                    if(e < index.length){e = e};
                    if(i >= proximo_mes.length){i = i};
                  }}
                  style={() => {if(linha == 0 && coluna == e){return {filter : 'brightness(0.6)'}};
                  if(linha == 4 && coluna == i){return{filter : 'brightness(0.6)'}}
                  else{return{filter : 'brightness(1)'}}}}
                ></td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>

{linhas.map((linha)=>(
{colunas.map((coluna,e,i)=>(
{
如果(e=proximo_mes.length){i=i};
}}
style={()=>{if(linha==0&&coluna==e){return{filter:'brightness(0.6)};
如果(linha==4&&coluna==i){return{filter:'brightness(0.6)}
else{return{filter:'亮度(1)}}
>
))}
))}
像这样使用:

style={(linha == 0 && coluna == e) ? {filter : 'brightness(0.6)'} : (linha == 4 && coluna == i) ? {filter : 'brightness(0.6)'} :  {filter : 'brightness(1)'}}
或者这个:

style={{filter :(linha == 0 && coluna == e) ? 'brightness(0.6)' : (linha == 4 && coluna == i) ?'brightness(0.6)' : 'brightness(1)'}}
由于返回的是
函数
而不是
对象
,因此会发生错误,请检查以下示例:

console.log(“函数样式:”{
风格:()=>{
如果(真){
返回{filter:“亮度(0.6)”};
}
}
})
console.log(“三元样式:”{
样式:true?{filter:“亮度(0.6)”}:{filter:“亮度(1)”}

})
非常感谢,但是你能告诉我为什么我的不起作用吗?没问题,请再次检查答案,我为这种情况举了一个例子。