簡體   English   中英

使用語義ui表時反應錯誤

[英]error in react when using semantic ui table

我使用語義UI創建表。 我想將表行屬性設置為positive 像這樣 :

<Table.Row positive>

這是我的代碼:

  <Table.Row {this.props.email.success ? "positive" : "negative"}>

但是發生此錯誤:

./src/components/EmailItem.js
Syntax error: ... src/components/EmailItem.js: Unexpected token, expected ... (7:18)

   5 |   render() {
   6 |     return (
>  7 |       <Table.Row {this.props.email.success ? "positive" : "negative"}>
     |                   ^
   8 |         <Table.Cell>
   9 |           {this.props.email.from}
  10 |         </Table.Cell>

我怎樣才能解決這個問題 ?

嘗試這個。

<Table.Row positive={!!this.props.email.success} negative={!this.props.email.success}>

並檢查一下- 如何有條件地向React組件添加屬性?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM