H5加载高德地图时候异步创建script标签
<script>
import MapLoader from '@/utils/AMap.js'
export default {
props: {
searchKey: {
type: String,
default: ""
}
},
watch: {
searchKey: {
handler: function (val) {
this.$nextTick(() => {
this.searchByHand();
});
},
deep: true
},
markers: function (val) {
// this.$emit('sendCoordinate', this.markers[0].position)
},
},
beforeMount() {
let that = this
MapLoader().then(AMap => {
console.log('地图加载成功')
that.map = new AMap.Map("amap-box", {
resizeEnable: true,
center: [121.329402, 31.228667],
zoom: 11,
});
}, e => {
console.log('地图加载失败', e)
})
},
data() {
let self = this;
return {
address: null,
markers: [],
searchOption: {
city: