vue3使用百度地图
vue.config.js
module.exports = {configureWebpack: {
externals: {
"BMap": "BMap",
'BMap_Symbol_SHAPE_POINT': 'BMap_Symbol_SHAPE_POINT'
}
}
}
.eslintrc.js
module.exports = {
globals: { BMap: true
}
}
shims-BMap.d.ts
declare module 'BMap' {
const BMap: anyexport default BMap
}
map.vue
<template>
<div class="diyu"> <div id="container" style="width: 800px;height: 800px"></div>
</div>
</template>
<script lang="ts">
import { defineComponent,onMounted } from 'vue'
import BMap from 'BMap'
export default defineComponent({
setup() { const methods= {
getditu(){
var map = new BMap.Map('container')
var point = new BMap.Point(116.404, 39.915)
map.centerAndZoom(point, 15)
map.enableScrollWheelZoom(true)
}
}
onMounted(() => {
})
return{...methods}
},
})
</script>
<style >
.bm-view {
width: 100%;
height: 300px;
}
</style>
没用求解
以上是 vue3使用百度地图 的全部内容, 来源链接: utcz.com/p/936571.html