我正在尝试学习如何通过包react-konva使用canvas。我找到了我需要在 javascript 中编写的确切内容,但我需要像反应组件一样,并在单击按钮时添加矩形的图像。任何人都可以帮我重新组织代码以在反应中显示它......这是我在网上找到的小提琴...... https://jsfiddle.net/kiksy/jqo2h3dx/2/
const stage = new Konva.Stage({
container: 'container',
width: window.innerWidth,
height: window.innerHeight,
draggable: true
});
const layer = new Konva.Layer();
stage.add(layer);
const WIDTH = 100;
const HEIGHT = 100;
const grid = [
['red', 'yellow'],
['green', 'blue']
];
const blocks = [
{ w: 150, h: 150 , background: "white" , image: "/img/test2.png" , fullImage: false, title: "" , text: "" },
{ w: 150, h: 150 , background: "white" , image: "/img/person-icon.png" , fullImage: false ,title: …Run Code Online (Sandbox Code Playgroud)