如何检查是否在vue中启用了位置服务
how to check is location service enabled in vue
我在 nuxt 中的应用程序,我只想检查是否启用了位置服务,否则如果未启用,则触发模态显示正常消息。
<b-modal id="show-ask-location" hide-footer>
<template v-slot:modal-title>
Please Allow your location for best results
</template>
<b-button class="mt-3" block @click="getCurrentLocation"
>Click here to allow location</b-button
>
</b-modal>
否则它不应该触发模态this.$bvModal.show('show-ask-location');
我找不到任何关于此的教程或文档请帮助
在您的组件中,使用计算的 属性 来检测地理位置:
...
computed: {
canGeolocate() {
return !!navigator.geolocation
}
}
...
并通过 v-if="canGeolocate"
在模板的任何地方使用它。
我在 nuxt 中的应用程序,我只想检查是否启用了位置服务,否则如果未启用,则触发模态显示正常消息。
<b-modal id="show-ask-location" hide-footer>
<template v-slot:modal-title>
Please Allow your location for best results
</template>
<b-button class="mt-3" block @click="getCurrentLocation"
>Click here to allow location</b-button
>
</b-modal>
否则它不应该触发模态this.$bvModal.show('show-ask-location');
我找不到任何关于此的教程或文档请帮助
在您的组件中,使用计算的 属性 来检测地理位置:
...
computed: {
canGeolocate() {
return !!navigator.geolocation
}
}
...
并通过 v-if="canGeolocate"
在模板的任何地方使用它。