问题描述
我正在使用 React Native Expo 开发移动应用程序。我正在使用 react-native-google-places-autocomplete
进行位置/地点的文本自动完成。它是谷歌 API。我已经创建了帐户,启用了谷歌服务并添加了我的帐单信息。但是代码不起作用。
查看下面的代码:
<View style={{height: 500}}>
<GooglePlacesAutocomplete
fetchDetails={true}
placeholder='Search'
onPress={(data,details = null) => {
console.log(data,details);
}}
query={{
key: 'my-api-key-here',language: 'en',}}
/>
</View>
我能够成功看到我可以输入的 Search
占位符,但我无法看到 google 的建议/自动完成文本。我可以在框中成功输入位置,但 google 没有提供位置建议。
我也安装并导入了相关的库。
解决方法
您需要添加道具 listViewDisplayed={boolean or "auto"}。请参阅此链接 https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example