【发布时间】:2018-09-30 06:13:17
【问题描述】:
我有一个我想有条件地定义的标签
<Table.Cell positive>{item}</Table.Cell>
那么,正确的做法是什么? 我所做的是用函数代替它
{this.callme(item)}
然后函数返回这个
callme = (item) => {
let res;
if (item && item > 3)
res = <Table.Cell positive>{item}</Table.Cell>
else if (item && item < -3)
res = <Table.Cell negative>{item}</Table.Cell>
else if (item)
res = <Table.Cell>{item}</Table.Cell>
else
res = <Table.Cell>..</Table.Cell>
return res;
但这很冗长。然后我尝试修改标签 inside 的东西,但这是不允许的
<Table.Cell {mystate}>{item}</Table.Cell>
然后是问题。如何修改标签本身?应该怎么写?
【问题讨论】:
标签: reactjs semantic-ui semantic-ui-react