Попробуйте добавить прослушиватель событий в методе mounted
в своем компоненте и указать его обработчик на метод компонента, например:
export default {
data() {
return {
location: null,
}
},
mounted() {
document.addEventListener('deviceready', this.onDeviceReady, false)
},
beforeDestroy() {
// remember to remove event listener
document.removeEventListener('deviceready', this.onDeviceReady)
},
methods: {
onDeviceReady() {
BackgroundGeolocation.on('location', this.handleLocation)
},
handleLocation(location) {
// you've got location!
this.location = location
}
}
})