在vue專案中引入高德地圖
阿新 • • 發佈:2018-12-11
1 在index.html檔案中引入js檔案<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.0&key="></script>
2 334
3
<template> <div id="container" class="mymap"></div> </template>
<script> import AMap from 'AMap'
export default { name: 'Address', data () { return {
} }, mounted(){ this.loadmap(); //載入地圖和相關元件 }, methods: { loadmap(){ const map = new AMap.Map('container', { zoom: 9 }); } } } </script>
<style scoped> .mymap{ width: 100%; height: 300px; } </style>