【问题标题】:OnSelect dosnt work with react-Google-places-autocompleteOnSelect 不适用于 react-Google-places-autocomplete
【发布时间】:2020-08-27 09:22:17
【问题描述】:

我用 react js 构建了一个表单,我想在 google-auto complete 中包含位置,所以我找到了这个库:

https://github.com/Tintef/react-google-places-autocomplete#readme

它对我来说很好用了 2 周,但是当我打印 OnSelect 的值时突然我什么也没看到。 在我的控制台上弹出这条黄色消息:

Select-073d29ba.esm.js:749 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

我的组件:

<div>
    <GooglePlacesAutocomplete
      onSelect={console.log}
 />

建议发生了什么?

【问题讨论】:

  • 我不知道发生了什么,但我使用的是 'react-google-autocomplete' 和它的不错,在 react-google-autocomplete 中它的 "onPlaceSelected" 而不是 onSelect。
  • 我尝试了“react-google-autocomplete”,但图书馆找不到很多城市。例如“特拉维夫”,它适合你吗?
  • 是的,它有效。也是希伯来语。您必须将“类型”添加到 组件 - types={['geocode']}。

标签: reactjs google-api


【解决方案1】:

我遇到了同样的问题,问题是最新版本的 react-google-places-autocomplete 仍处于 ALPHA 和 BETA 测试中,而且还不稳定。

只要使用2.3.2版本就可以解决问题。

运行命令:

npm install --save react-google-places-autocomplete@2.3.2

【讨论】:

    猜你喜欢
    • 2020-05-27
    • 1970-01-01
    • 2019-09-19
    • 1970-01-01
    • 2018-01-08
    • 2014-02-28
    • 2017-08-13
    • 2018-12-20
    • 1970-01-01
    相关资源
    最近更新 更多