报错描述
给 <baidu-map></baidu-map> 绑定了地图初始化事件 @ready="initMap"
- 在方法 initMap({BMap, map}) {} 中 BMap 可以正常使用
- 在其他方法/生命周期中,一旦使用 BMap ,便报错提示 BMap is undefined
解决方案
1. 全局安装 ESlint (任意目录下的命令行中执行)
npm install eslint -g
2. 在项目文件夹下新建文件.eslintrc.js
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "plugin:vue/essential",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"vue"
],
"rules": {
}
};