2017-09-14 34 views
0

我試圖在用戶單擊時在按鈕上添加加載狀態登錄直到登錄函數返回一些內容。在按鈕上添加加載狀態 - Reactjs Shopify Polaris

簡單的按鈕是這樣的:

<Button primary onClick={this.handleSubmit}></Button> 

和加載按鈕是這樣的:

<Button primary onClick={this.handleSubmit} Loading></Button> 

所以我想補充Loading屬性轉換按鈕,當用戶點擊了它,但我在下面的代碼得到錯誤:

這裏是按鈕代碼:

<Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button> 

錯誤:

Syntax error: Unexpected token, expected ... (64:61) 
AT: <Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button> 
               ^

如何,我想在Button組件

PS添加加載屬性。我使用Shopify Polaris Components

回答

2

更改爲

<Button primary onClick={this.handleSubmit} Loading={this.state.buttonloading}>Login</Button> 
+0

大謝謝:) –

+0

@Giang樂,你能添加說明,它會確保這個答案是完整的:) –

+0

「加載」被稱爲「道具」。在「Button」組件中,它調用「this.props.Loading」,如果爲true,則設置「加載到組件按鈕」。他們使用簡短的語法「加載」,而不是加載= {true}。對不起,我的英語不好 –