laravel - Vue.js - 地理定位不适用于移动设备......为什么?

标签 laravel mobile vue.js

我尝试使用 Vue 组件访问地理定位 - 在 Desktopbrowers 上它可以工作,但是在移动浏览器上它不起作用......

测试地址 http://www.padermeet.de/geolocation

这是什么原因?

<template>
    <div>
        <p>Click the button to get your coordinates.</p>
        <button @click="getLocation">Try It</button>
        <p id="demo" v-text="text"></p>
    </div>
</template>

<script>
    export default {
        data(){
            return {
                text: 'Hier wird deine Latitude und Longitude angezeigt.',
                lat: '',
                lng: ''
            }
        },
        methods: {
            getLocation() {
                if (window.navigator.geolocation) {
                    window.navigator.geolocation.getCurrentPosition(this.showPosition);
                } else { 
                    text = "Geolocation is not supported by this browser.";
                }
            },
            showPosition(position) {
                this.lat = position.coords.latitude,
                this.lng = position.coords.longitude,
                this.text = "deine Location befindet sich in: Latitude:" + this.lat + " und Longitude: " + this.lng;
            } 

        }
    }
</script>

<style lang="scss">
</style>

最佳答案

chrome 上的地理位置不适用于非安全来源。

Deprecation] getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS.

您需要一个 https 才能正确处理它。

引用

https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins

希望对你有帮助

关于laravel - Vue.js - 地理定位不适用于移动设备......为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49096855/

相关文章:

javascript - 调试用 Testcafe 编写的 UI 测试

javascript - VueJS 2 - 如何使用 $emit 传递参数

reactjs - Guzzle:无法捕获异常详细信息

html - 我设置的边距在移动设备上消失了

typescript - 使用 Vue 3 Composition API 创建全局商店

android - 移动开发的 future

reactjs - Material UI - 响应式抽屉

laravel - 不要在 Blade 中显示获取参数

php - 错误 : No application encryption key has been specified. 但它存在

php - Laravel,sync() - 如何同步数组并传递额外的数据透视字段?