我做簡單的屏幕只包含一個帶佔位符的TextInput,但佔位符顯示。哪裏不對?react-native TextInput佔位符不可見
爲MyComponent:
render() {
<TextInput
placeHolder="placeholder"
/>
}
index.js:
export default() => {
<MyComponent />
}
包裝的TextInput到視圖沒有幫助。
我做簡單的屏幕只包含一個帶佔位符的TextInput,但佔位符顯示。哪裏不對?react-native TextInput佔位符不可見
爲MyComponent:
render() {
<TextInput
placeHolder="placeholder"
/>
}
index.js:
export default() => {
<MyComponent />
}
包裝的TextInput到視圖沒有幫助。
看起來你拼錯道具placeholder
到placeHolder
。請參閱https://facebook.github.io/react-native/docs/textinput.html#placeholder。
嘗試這樣
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
},
其添加這個完全是因爲佔位符的錯誤拼寫的 - >佔位符。
render() {
<TextInput
placeholder="placeholder text"
/>
}