我一直试图找到一种方法来更改React本机中的GooglePlacesAutocomplete组件的占位符文本。我试着翻阅官方文件,但没有看到任何关于这方面的东西。有人有办法解决这个问题吗?我试过使用像placeholderTextColor这样的道具,这对我没有用。谢谢。
码
<GooglePlacesAutocomplete
renderLeftButton={() => <Icon name='location'
type='evilicon' color={colors.middlegray} style={styles.icon}/>}
placeholder="Where is it?"
styles={toInputBoxStyles}
returnKeyType={"search"}
fetchDetails={true}
name="location"
enablePoweredByContainer={false}
nearbyPlacesAPI="GooglePlacesSearch"
debounce={400}
value={searchWords.searchKeyword}
query={{
key: GOOGLE_MAPS_APIKEY,
language: 'en'
}}
onPress={(data, details = null) => {
setSearch({searchKeyword: data.description});
}}
/>发布于 2021-12-21 14:48:02
您可以使用textInputProps设置placeholderTextColor,如下所示:
<GooglePlacesAutocomplete
...
placeholder="Where is it?"
textInputProps={{
placeholderTextColor: '#32a852',
returnKeyType: "search"
}}
...
query={{
key: GOOGLE_MAPS_APIKEY,
language: 'en'
}}
onPress={(data, details = null) => {
setSearch({searchKeyword: data.description});
}}
/>你可以看到所有可用的道具这里
发布于 2021-12-21 05:28:57
更改GooglePlacesAutocomplete标记中的占位符vlaue。
import React from 'react';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
const GooglePlacesInput = () => {
return (
<GooglePlacesAutocomplete
placeholder='Enter your placeholder text here'
/>
);
};
export default GooglePlacesInput;发布于 2022-05-09 10:57:10
这个解决方案在React.js中对我有效。
<GooglePlacesAutocomplete
selectProps={{
placeholder: 'here is the placeholder text'
}}
/>
https://stackoverflow.com/questions/70430848
复制相似问题