vue-baidu-map 报错 | map is undefined

简介: vue-baidu-map 报错 | map is undefined

报错描述  

给 <baidu-map></baidu-map> 绑定了地图初始化事件 @ready="initMap"


  • 在方法 initMap({BMap, map}) {} 中 map 可以正常使用
  • 在其他方法/生命周期中,一旦使用 map,便报错提示 map is undefined

解决方案


1. 在data() 中定义map变量

        data() {
            return {
                map: '',


2. 在方法 initMap({BMap, map}) {} 中,保存map

        data() {
            return {
                map: '',


3. 在其他方法/生命周期中使用map时,使用 this.map

目录
相关文章
|
定位技术
vue-baidu-map 报错 | BMap is undefined
vue-baidu-map 报错 | BMap is undefined
434 1
|
JavaScript
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
488 0
|
JavaScript 前端开发
报错:Cannot read properties of undefined (reading ‘$message‘)解决方法
以上就是解决"Cannot read properties of undefined (reading ‘$message‘)"错误的几种方法,希望对你有所帮助。
7414 0
echarts 报错 —— Component series.map not exists. Load it first
echarts 报错 —— Component series.map not exists. Load it first
556 0
|
JavaScript 定位技术
vue 百度地图开发【教程】1. 绘制百度地图(不使用 vue-baidu-map,解决 BMap is undefined)
vue 百度地图开发【教程】1. 绘制百度地图(不使用 vue-baidu-map,解决 BMap is undefined)
726 0
|
前端开发 小程序 JavaScript
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
333 0
|
前端开发 JavaScript
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
509 0
webpack版本问题 Cannot read property ‘createHash‘ of undefined
webpack版本问题 Cannot read property ‘createHash‘ of undefined
362 1