Closed EdwardLiu601 closed 6 months ago
请填写使用版本: "@vuemap/vue-amap": "^2.1.1",
在使用ElAmapMarker组件时,Marker拖动会报错Uncaught TypeError: position.toArray is not a function 研究后发现拖动事件会执行emitPosition函数,
const emitPosition = () => { const position = $amapComponent.getPosition() as AMap.LngLat; emits('update:position', position.toArray()); };
position对象中缺少toArray方法
尝试切换了更低版本也存在这个问题
https://amap-run.guyixi.cn/#eyJzcmMvQXBwLnZ1ZSI6Ijx0ZW1wbGF0ZT5cbiAgPGRpdiBjbGFzcz1cIm1hcC1wYWdlLWNvbnRhaW5lclwiPlxuICAgIDxlbC1hbWFwXG4gICAgICA6c2hvdy1sYWJlbD1cImZhbHNlXCJcbiAgICAgIDpjZW50ZXI9XCJjZW50ZXJcIlxuICAgICAgOnpvb209XCJ6b29tXCJcbiAgICAgIEBjbGljaz1cImNsaWNrTWFwXCJcbiAgICAgIEBpbml0PVwiaW5pdE1hcFwiXG4gICAgPlxuICAgICAgPGVsLWFtYXAtbWFya2VyXG4gICAgICAgIHYtbW9kZWw6cG9zaXRpb249XCJjb21wb25lbnRNYXJrZXIucG9zaXRpb25cIlxuICAgICAgICA6dmlzaWJsZT1cImNvbXBvbmVudE1hcmtlci52aXNpYmxlXCJcbiAgICAgICAgOmRyYWdnYWJsZT1cImNvbXBvbmVudE1hcmtlci5kcmFnZ2FibGVcIlxuICAgICAgICBAaW5pdD1cIm1hcmtlckluaXRcIlxuICAgICAgICBAY2xpY2s9XCJjbGlja01hcmtlclwiXG4gICAgICA+XG4gICAgICAgIDxkaXYgc3R5bGU9XCJwYWRkaW5nOiA1cHggMTBweDt3aGl0ZS1zcGFjZTogbm93cmFwO2JhY2tncm91bmQ6IGJsdWU7Y29sb3I6ICNmZmY7XCI+XG4gICAgICAgICAg5rWL6K+VY29udGVudFxuICAgICAgICA8L2Rpdj5cbiAgICAgIDwvZWwtYW1hcC1tYXJrZXI+XG4gICAgPC9lbC1hbWFwPlxuICA8L2Rpdj5cbiAgPGRpdiBj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zdCBtYXJrZXJJbml0ID0gKGU6IGFueSkgPT4ge1xuICBjb25zb2xlLmxvZygnbWFya2VyIGluaXQ6ICcsIGUpO1xufVxuXG5cblxuPC9zY3JpcHQ+XG5cbjxzdHlsZSBzY29wZWQ+XG48L3N0eWxlPlxuIiwiaW1wb3J0LW1hcC5qc29uIjoie1xuICBcImltcG9ydHNcIjoge31cbn0iLCJ0c2NvbmZpZy5qc29uIjoie1xuICBcImNvbXBpbGVyT3B0aW9uc1wiOiB7XG4gICAgXCJ0YXJnZXRcIjogXCJFU05leHRcIixcbiAgICBcImpzeFwiOiBcInByZXNlcnZlXCIsXG4gICAgXCJtb2R1bGVcIjogXCJFU05leHRcIixcbiAgICBcIm1vZHVsZVJlc29sdXRpb25cIjogXCJCdW5kbGVyXCIsXG4gICAgXCJ0eXBlc1wiOiBbXCJAdnVlbWFwL3Z1ZS1hbWFwL2dsb2JhbC5kLnRzXCIsXCJAdnVlbWFwL3Z1ZS1hbWFwLWxvY2EvZ2xvYmFsLmQudHNcIixcIkB2dWVtYXAvdnVlLWFtYXAtZXh0cmEvZ2xvYmFsLmQudHNcIl0sXG4gICAgXCJhbGxvd0ltcG9ydGluZ1RzRXh0ZW5zaW9uc1wiOiB0cnVlLFxuICAgIFwiYWxsb3dKc1wiOiB0cnVlLFxuICAgIFwiY2hlY2tKc1wiOiB0cnVlXG4gIH0sXG4gIFwiaW5jbHVkZVwiOiBbXCJ0eXBpbmdzLyoqLypcIl0sXG4gIFwidnVlQ29tcGlsZXJPcHRpb25zXCI6IHtcbiAgICBcInRhcmdldFwiOiAzLjNcbiAgfVxufVxuIiwidHlwaW5ncy9nbGJhbC5kLnRzIjoiZGVjbGFyZSBjb25zdCBBTWFwOiBhbnlcbmRlY2xhcmUgY29uc3QgTG9jYTogYW55XG4iLCJfbyI6e319
你可以看下这个示例,没有出现报错情况,你可以把你报错的示例贴一下,我看下什么原因
你是不是使用了1.4.X版本的JSAPI,组件库没有对1.4做完全兼容,如果需要使用1.4,推荐还是用原生JS写
还真是JSAPI版本的问题,改成2.0的就不报错了,感谢答复
使用版本
请填写使用版本: "@vuemap/vue-amap": "^2.1.1",
问题描述
在使用ElAmapMarker组件时,Marker拖动会报错Uncaught TypeError: position.toArray is not a function 研究后发现拖动事件会执行emitPosition函数,
position对象中缺少toArray方法
尝试切换了更低版本也存在这个问题