2017-09-26 19 views

답변

1

TextInput 구성 요소에 조건부 스타일을 지정할 수 있습니다.

_onChangeText(text) { 
    this.setState({ fontSize: (text.lenght > 6 ? 40 : 80) }); 
} 

render() { 
    return (
    // Giving an array of objects to style property can help you to define a default value 
    <TextInput 
     onChangeText={this._onChangeText.bind(this)} 
     style={[ {fontSize: 80}, {fontSize: this.state.fontSize} ]} 
    /> 
) 
} 
+0

가 보여주는 null가 – Vijay

+0

당신은 당신의 생성자 메서드에 상태의 초기 값을 줄 필요가있다 ('this.state.fontSize을'평가) 대상이 아닙니다. – bennygenel

+0

텍스트의 길이는 0에서 시작해야합니까? 생성자 (소품) { super (소품); this.state = { 개수 : 0, } } 이같은가요? @bennygenel – Vijay