我在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
}
}
...