reactjs - Google API - 在 React Native Expo 项目中放置自动完成功能
问题描述
我正在使用 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
我可以输入的占位符,但我无法看到谷歌的建议/自动完成文本。我可以在框中成功输入位置,但谷歌没有提供位置建议。
我也安装并导入了相关库。
解决方案
您需要添加道具 listViewDisplayed={boolean or "auto"}。请参阅此链接https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example
推荐阅读
- wpf - 如何在显示子内容时隐藏父控件?
- android - 无法从 SQLite 数据库中删除一些记录
- dart - Flutter - 关闭小部件时 BLoC 流实例会导致内存泄漏吗?
- docker - Docker 硬件虚拟化与 virtualbox vms 冲突
- python - 使用 2 列和 pandas 中第三列的值创建 dict 的 dict
- php - 如何在 wordpress 管理员和用户端使用相同的对象?
- python - 如何在 Jupyter Notebook 中使用 sklearn 树和 export_graph_viz 调整树的图像大小
- javascript - 最小最大百分比的短(er)手?
- mysql - 提交或页面重新加载后如何在选择框中保留选定的值是从数据库中检索的值和选项不同?
- javascript - 如何从包含在 html 表格列中的日期中提取月份?