openlayers 点击右键菜单怎么阻止它触发map 的点击事件

img


如上所示,我点击的是菜单项 但它会触发map的点击事件新增了一个点,怎么阻止这种行为?

有可能是事件冒泡了,在菜单点击事件使用e.stoppropagation()试试

阻止一下右键的默认点击事件
window.oncontextmenu = function (e) {
// 阻止默认行为
e.preventDefault()
console.log('右键单击了')
}
试一试