vue引入百度地图api组件封装(根据地址定位)
Map.vue
<template>
<div class="Map" :style="{
height: this.height+'px',
this.width+ 'px'
}">
<div attribute to limit CSS to this component only -->
<style scoped>
#allmap {
height: 100%;
100%;
}
</style>
map.js
export function MP(ak) { return new Promise(function (resolve, reject) { window.init = function () { resolve(BMap) } var script = document.createElement("script"); script.type = "text/javascript"; script.src = "http://api.map.baidu.com/api?v=2.0&ak="+ak+"&callback=init"; script.onerror = reject; document.head.appendChild(script); }) }
你们的支持,是我坚持的动力~