<el-col :span="24" >
            	<div style="width:100%;height:300px;" id="allmap"></div>
        </el-col> 
 
  
        import {MP} from '../../../util/baiDuMap'
setTimeout在vue里需生命变量this, 参数是函数
    let _this=this
    setTimeout( function()  { _this.path=arr;  _this.play = true;},idx*10)
  mounted() {
  this.$nextTick(function(){
       MP().then(BMap => {
        //在此调用api
 	var map = new BMap.Map("allmap");    // 创建Map实例
 	map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);  // 初始化地图,设置中心点坐标和地图级别
	
 	map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
 	map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
       });
       })
}
 
  
baiDuMap.js文件
export function MP() {
    return new Promise(function (resolve, reject) {
      window.onload = function () {
        resolve(BMap)
      }
      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = "http://api.map.baidu.com/api?v=2.0&ak=TI7gCHQoTkipcLw50VvOSYYP&callback=init";
      script.onerror = reject;
      document.head.appendChild(script);
      
    })
  }