2016-02-18 12 views

回答

0

您可以在您的狀態下設置顏色,然後使用onFocus事件對狀態進行更改。下面是一個簡單的例子。

原始應用程序狀態(ES6構造函數):

constructor() { 
     this.state = { 
      floatingErrorText: 'This field is required.',  
      floatingTextColor: {color: 'blue'} 
     } 
    } 

您的文本字段:

<TextField 
    hintText="Project Name" 
    errorText={this.state.floatingErrorText} 
    floatingLabelText="Project Name" 
    floatingLabelStyle={this.state.floatingTextColor} 
    onFocus={this.handleFocus.bind(this)} /> 

然後改變沿着這些線路的狀態用的東西:

handleFocus(){ 
     this.setState({floatingTextColor: {color: 'orange'}}); 
    } 
+0

酷。謝謝凱西。 –