ITPub博客

首页 > 数据库 > > algolia_将Algolia场所与Vuetify一起使用

algolia_将Algolia场所与Vuetify一起使用

作者:LCR_ 时间:2022-04-27 15:46:46 0 删除 编辑

algolia

Vuetify阿尔戈利亚的地方 (Vuetify Algolia Places)

Use Algolia Places with Vuetify.

将Algolia Places与Vuetify一起使用。

安装 (Installation)

Run in your terminal:

在您的终端中运行:

yarn add vuetify-algolia-places

You also need to install algoliasearch and places.js:

您还需要安装algoliasearch和places.js :

yarn add '[email protected]^3' '[email protected]^1'

Then install the plugin:

然后安装插件:

  1. import Vue from 'vue';
  2. import VuetifyAlgoliaPlaces from 'vuetify-algolia-places';
  3. Vue.use(VuetifyAlgoliaPlaces, {
  4. algolia: {
  5. appId: '...', // Optional
  6. apiKey: '...', // Optional
  7. },
  8. });

用法 (Usage)

Vuetify Algolia Places is still under development, so for now there is no way to specify props nor events.

Vuetify Algolia Places仍在开发中,因此目前尚无法指定道具或活动。

<vuetify-algolia-places v-model="place" />

The variable place looks like this:

可变place如下所示:

  1. {
  2. "name": "30 Rue du Sergent Michel Berthet",
  3. "administrative": "Auvergne-Rhône-Alpes",
  4. "city": "Lyon 9e Arrondissement",
  5. "country": "France",
  6. "countryCode": "fr",
  7. "type": "address",
  8. "latlng": {
  9. "lat": 45.7704,
  10. "lng": 4.80536
  11. },
  12. "postcode": "69009",
  13. "highlight": {
  14. "name": "<em>30</em> <em>Rue</em> <em>du</em> <em>Sergent</em> <em>Michel</em> <em>Be</em>rthet",
  15. "city": "Lyon 9e Arrondissement",
  16. "administrative": "Auvergne-Rhône-Alpes",
  17. "country": "France"
  18. },
  19. "hitIndex": ,
  20. "query": "30 rue du sergent michel berthet",
  21. "value": "30 Rue du Sergent Michel Berthet, Lyon 9e Arrondissement, Auvergne-Rhône-Alpes, France"
  22. }
关于初始值的注意事项 (Note about initial value)

If you don't store this kind of object in your application, you can still pass a plain string that is equivalent to the value value, e.g.: 30 Rue du Sergent Michel Berthet, Lyon.

如果没有这种类型的对象存储在您的应用程序,您还可以通过一个简单的字符串,它等效于值value ,例如: 30 Rue du Sergent Michel Berthet, Lyon 。

If this value is not null during the initialization of the component, it will automatically request Algolia API and use the first hit.

如果在组件初始化期间该值不为null ,它将自动请求Algolia API并使用第一个匹配项。

That means if place is equal to 30 Rue du Sergent Michel Berthet, Lyon, it will be automatically transformed to the above JSON object.

这意味着如果place等于30 Rue du Sergent Michel Berthet, Lyon ,它将被自动转换为上述JSON对象。

道具 (Props)

NameTypeAlgolia Places documentation
typeStringCheck type option
languageStringCheck language option
countriesString[]Check countries option
aroundLatLngStringCheck aroundLatLng option
aroundLatLngViaIpBooleanCheck aroundLatLngViaIP option
aroundRadiusNumberCheck aroundRadius option
名称类型Algolia Places文档
typeString检查type选项
languageString检查language选项
countriesString[]检查countries选项
aroundLatLngString检查aroundLatLng选项
aroundLatLngViaIpBoolean检查aroundLatLngViaIP选项
aroundRadiusNumber检查aroundRadius选项

Every props from Vuetify Autocomplete component are supported, except items, loading, search-input.sync, filter and return-object that are used internally.

支持Vuetify Autocomplete组件中的每个道具,但内部使用的items , loading , search-input.sync , filter和return-object除外。

大事记 (Events)

NameDescriptionArguments
inputEmitted when the user select a place@input="onInput", onInput(place) { }
errorEmitted when there is an error with Algolia API@error="onError", onError(error) { }
clearEmitted when the user click on the clear button (used with prop clearable)@clear="onClear", onClear() { }
名称描述争论
input用户选择地点时发出@input="onInput" , onInput(place) { }
errorAlgolia API错误时发出@error="onError" , onError(error) { }
clear当用户单击清除按钮时发射(与prop clearable )@clear="onClear" , onClear() { }

翻译自: https://vuejsexamples.com/use-algolia-places-with-vuetify/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70000523/viewspace-3160132/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: InfiniteGraph
请登录后发表评论 登录
全部评论

注册时间:2022-02-22

  • 博文量
    1402
  • 访问量
    15036