1.安装:
npm install vue-amap --save
2.main.js引入:
import VueAMap from 'vue-amap';
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
key: 'key',//自己申请的key
plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.Geocoder','AMap.Geolocation'],
v: '1.4.4'
});
3.组件中使用:
<template>
<div class="hello">
<el-amap vid="amapDemo" :center="center" :zoom="zoom" :plugin="plugin" :events="events" class="amap-demo">
<el-amap-marker v-for="(marker, index) in markers" :position="marker.position" :events="marker.events" :visible="marker.visible"
:draggable="marker.draggable" :vid="index"></el-amap-marker&g