问题描述
在调用路书组件,开启自动转弯功能(rotation为 true)时,当小车在地图轨迹上转弯,会出现以下问题
Uncaught TypeError: Cannot read properties of undefined (reading 'x')
解决方法
// template
<bml-lushu
:play="mapConfig.play"
:path="mapConfig.path"
:icon="icon"
:speed="mapConfig.speed"
:auto-view="true"
:rotation="true"
@stop="handleReset"
/>
// script
data.forEach(item => {
this.mapConfig.path.push(
new this.BMap.Point(item.longitude, item.latitude)
)
})
// BMap 来自于地图Ready 事件中的参数
// handler({ BMap, map }) {
// this.BMap = BMap
// }
参考