2016-11-17 48 views
0

我做簡單的屏幕只包含一個帶佔位符的TextInput,但佔位符顯示。哪裏不對?react-native TextInput佔位符不可見

爲MyComponent:

render() { 
    <TextInput 
    placeHolder="placeholder" 
    /> 
} 

index.js:

export default() => { 
    <MyComponent /> 
} 

包裝的TextInput到視圖沒有幫助。

回答

0

嘗試這樣

render() { 
    <TextInput 
    placeholder="placeholder text" 
    /> 
} 

這樣你就可以測試你的組件

<TextInput 
      style={styles.textEdit} 
      onChangeText={(text) => this.setState({text})} 
      placeholder="add text here to see in place holder" 
     /> 

風格

textEdit: { 
    height: 40, 
    borderColor: 'grey', 
    backgroundColor: 'white', 
    borderWidth: 1 
    }, 
0

其添加這個完全是因爲佔位符的錯誤拼寫的 - >佔位符。

render() { 
 
    <TextInput 
 
    placeholder="placeholder text" 
 
    /> 
 
}