反应地点自动完成限制

Rom*_*ina 1 google-maps autocomplete reactjs

我刚开始使用react-places-autocomplete库,但找不到如何将预测限制到指定国家/地区。

我可以为 google maps autocomplete ComponentRestrictions找到它,但不能为react-places-autocomplete库找到它

是否可以?

Ale*_*ias 9

//只是使用

 <PlacesAutocomplete
    searchOptions={searchOptions}
Run Code Online (Sandbox Code Playgroud)

//并添加一个常量

const searchOptions = {
  componentRestrictions: { country: ['us'] },
  types: ['city']
}
Run Code Online (Sandbox Code Playgroud)