var mode = 'brush'; var lastLine = new Konva.Line({ stroke: '#df4b26', strokeWidth: 5, globalCompositeOperation: mode === 'brush' ? 'source-over' : 'destination-out', points: [pos.x, pos.y] }); that.layer.add(lastLine); 界面上没有线条显示内容:这段代码创建了一个 Konva.Line 对象并将其添加到了一个图层中,但是没有将图层添加到舞台上显示出来。你需要将图层添加到舞台上才能看到线条。

假设你已经创建了一个 Konva.Stage 对象,并将其存储在变量 stage 中,你可以使用以下代码将图层添加到舞台上显示出来:

stage.add(that.layer);

这样,你就可以在界面上看到线条了。

Konva.js: 图层未显示到舞台上的解决方案

原文地址: https://www.cveoy.top/t/topic/pd2E 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录