*官网https://elemefe.github.io/vue-amap/#/zh-cn/introduction/install

1.安装依赖

  1. npm install vue-amap --save

2.在main.js中引入amap

  1. import VueAMap from 'vue-amap';
  2. Vue.use(VueAMap);
  3. VueAMap.initAMapApiLoader({
  4. key: 'your amap key',
  5. plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
  6. // 默认高德 sdk 版本为 1.4.4
  7. v: '1.4.4'
  8. });

3.使用

  1. <template>
  2. <div>
  3. <el-amap ref="map" vid="amapDemo" :center="center" :zoom="zoom" class="amap-demo">
  4. </el-amap>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name:"My",
  10. data(){
  11. return{
  12. center: [114.504267,30.552742],
  13. zoom: 12,
  14. }
  15. },
  16. mounted(){
  17. }
  18. }
  19. </script>
  20. <style lang="scss" scoped>
  21. .amap-demo {
  22. height: 400px;
  23. }
  24. </style>