vue使用vue-amap组件报错AMap is not defined
日常开发中我们使用到vue-amap组件会导致浏览器报两个错误
1.Error in mounted hook: "ReferenceError: AMap is not defined"
2.AMap is not defined
我查阅了很多资料,大多数都是根目录新建eslintrc.js文件
但即使这样设置了globals,浏览器也依然报错
虽然说使用setTimeout方法也能解决,但我总感觉不太美观
最后面查阅不到想要的解决方式了,只能埋头去查阅vue-amap官方文档
其实只需要在使用了el-amap组件的页面中引入lazyAMapApiLoaderInstance即可解决这两个报错
这样即使在当前地图页面ctrl+r,console控制台也不会报错了。