我正在尝试在样式中创建一条if语句,但是在样式if语句中不断出现 Expected an assignment or function call and instead saw an expression
错误。我试图修复/* eslint-disable */
的问题,但错误更改为 The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.
。有人知道我在做什么错吗?
import React, { useState } from 'react'
export default function Calendar() {
return(
<div>
<table id='calendario'>
<tbody>
{lines.map((linha) => (
<tr key={linha}>
{columns.map((coluna , e , i) => (
<td
key={coluna} onLoad={() => {
e < index.length ? (e = e) : e++;
i >= proximo_mes.length ? (i = i) : i++;
}}
style={() => {linha == 0 && coluna == e ? {filter:"brightness(0.6)"} : {filter:"brightness(1)"};
linha == 4 && coluna == i ? {filter:"brightness(0.6)"} : {filter:"brightness(1)"}}}
>{dias_no_mes[indice++]}</td>
))}
</tr>
))}
</tbody>
</table>
</div>
);
}
}
最佳答案
我认为样式 Prop 值应类似于以下内容,因为期望值
<td
...
style={{ filter: linha == 0 && coluna == e ? "brightness(0.6)" : "brightness(1)" }}
>
关于javascript - 需要一个赋值或函数调用,而是看到一个表达式React JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65606012/