在 react-konva 中更改 Hover 上的光标

SSP*_*ude 3 javascript frontend reactjs react-konva konva

我正在使用 react-konva 为应用程序创建 UI。我希望它使光标在悬停在 Rect 上时变为指针。有关于如何使用 konva 但没有关于 react-konva 的文档。任何人都可以帮忙吗?

lav*_*ton 8

它的工作原理与 Konva 演示非常相似。

<Rect
  width={50}
  height={50}
  fill="red"
  onMouseEnter={e => {
    // style stage container:
    const container = e.target.getStage().container();
    container.style.cursor = "pointer";
  }}
  onMouseLeave={e => {
    const container = e.target.getStage().container();
    container.style.cursor = "default";
  }}
/>
Run Code Online (Sandbox Code Playgroud)

演示:https : //codesandbox.io/s/react-konva-cursor-style-demo-96in7