Tengo un problema en Konva, esta secuencia de comandos dibuja algunos puntos y líneas entre el punto y lo que se puede arrastrar. Quiero seleccionar las líneas o los puntos y cuando paso el mouse o hago clic en la línea/punto creado, aparece un error, por ejemplo: Error de tipo no capturado: no se puede leer. propiedades de undefined (leyendo 'newLine')
function updateObjects() { var shapes = stage.find('.line'); shapes.forEach((shape) => { shape.destroy(); }) targets.forEach((target) => { (function () { if (targets.length > 1) { if (target.id != targets.length - 1) { const targid = '#targets' + target.id; const targid2 = '#targets' + (target.id + 1); var ctarg = stage.find(targid)[0]; var entarg = stage.find(targid2)[0]; if (ctarg != null && entarg != null) { var newLine = new Konva.Line({ points: [ctarg.x(), ctarg.y(), entarg.x(), entarg.y()], stroke: 'black', strokeWidth: 5, lineCap: 'round', lineJoin: 'round', id: 'lineId=' + idCounter, name: 'line', }); idCounter++; //become an error on THIS this.newLine.on('mouseover', () => { document.body.style.cursor = 'pointer'; this.strokeWidth(12); }); layerLines.add(newLine); stage.add(layerLines); stage.add(layer); } } } })(); });}
en this.strokeWidth(xx); tengo un error
Error de alcance simple en su código - nueva línea r = declarado como
var newLine
luego referido como
this.newLine
¿Tal vez cometió un error al preparar su código de muestra para publicarlo?