Vue cdn引入百度地图导致的页面滚动问题

loadBMap() {
        return new Promise(function(resolve, reject) {
            if (typeof window.BMap !== 'undefined') {
                                setTimeout(e=>{
                    //百度地图加载之后导致页面可滚动问题
                    let iframe = document.body.childNodes[document.body.childNodes.length -1];
                    document.body.removeChild(iframe);
                },1000);
                resolve(window.BMap)
                return true
            }
            window.onBMapCallback = function() {
                resolve(window.BMap)
            }
            let script = document.createElement('script')
            script.type = 'text/javascript'
            script.src =
                'http://api.map.baidu.com/api?v=3.0&ak=7RMy465oWLk4VlLGTkMG7sVSXU4zt1LP&callback=onBMapCallback'
            script.onerror = reject
            document.head.appendChild(script)
        })
    },

    location(success, faile) {
        this.loadBMap().then(BMap => {
            setTimeout(e=>{
                //百度地图加载之后导致页面可滚动问题
                let iframe = document.body.childNodes[document.body.childNodes.length -1];
                document.body.removeChild(iframe);
            },1000);
            try {
                var geolocation = new BMap.Geolocation();
                geolocation.getCurrentPosition(function(r) {
                    if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                        success(r.point);
                    } else {
                        faile(this.getStatus());
                    }
                });
            } catch (e) {
                Vue.prototype.$throw(JSON.stringify(e));
                faile(e)
            }
        }).catch(error => {
            Vue.prototype.$throw(JSON.stringify(error));
            faile(error)
        })
    },

你可能感兴趣的:(Vue cdn引入百度地图导致的页面滚动问题)