SVG在“填充:无"时检测Onclick事件.

问题描述:

当我使用"fill:black"创建svg rect时,将调用我的on_click事件处理程序.

When I create an svg rect with "fill: black", my on_click event handler gets called.

当我将"fill:black"替换为"fill:none"时,当我在矩形内部单击时,不会调用我的事件处理程序,而仅当我单击菜单项的 border 时才调用该事件处理程序直肠.

When I replace the "fill: black" with "fill: none", my event handler is NOT called when I click inside the rect, but only called when I click on the border of the rect.

问题:我需要更改什么,以便检测到单击矩形内 的单击事件?

Question: what do I need to change so that click events are detected for clicking inside the rectangle?

这由

This is controlled by the pointer-events property. Looks like you want to set it to visible

<rect pointer-events="visible" ...>