Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

413
Visualizações
GraphObject.make requires a class function or GoJS class name or name of an object builder, not: undefined

I'm following the tutorial of the library go.js: https://www.youtube.com/watch?v=EyseUD_i6Dw&list=PLOiCuGu6tcUSvKsqFnemvGTfdT97wVLsX&index=3.

I reached this point without problems, but at this point I'm getting this error:

GraphObject.make requires a class function or GoJS class name or name of an object builder, not: undefined

This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>

    <script src="https://unpkg.com/gojs@2.2.5/release/go.js"></script>
    <script>
        function init() {
            var $ = go.GraphObject.make;
            myDiagram = $(go.Diagram, "myDiagramDiv");
            myDiagram.add(
                $(go.Part, "Position",
                    $(go.Shape, "RoundedRectangle", {fill: "white"}),
                    $(go.textBlock, "some text")
                )
            );
            
        }
    </script>
</head> 
<body onload="init()">
    <div id="myDiagramDiv" style="height: 400px; width: 400px; border: 1px solid black;"></div>
    
</body>
</html>

Does anyone know where is the problem? Some version issue perhaps? I've tried with different versions of go.js, but I get always the same problem.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have misspelled go.TextBlock (you wrote go.textBlock)

By the way, in 2.2 (which was released after those videos were made), GoJS has a new way of constructing objects that looks like this:

function init() {
  myDiagram = new go.Diagram("myDiagramDiv");
  myDiagram.add(
    new go.Part("Position")
      .add(new go.Shape("RoundedRectangle", {fill: "white"}))
      .add(new go.TextBlock("some text"))
  );
}

This method chaining like new go.Part().add(someObject).add(anotherObject) allows you to write code that is concise like GraphObject.make, but the errors are more clear. In the case of your typo, instead you would see:

Uncaught TypeError: go.textBlock is not a constructor

And it would point out the specific line: enter image description here

Ro read more about method chaining instead of using GraphObject.make, see: https://gojs.net/latest/changelog.html

https://gojs.net/latest/intro/buildingObjects.html

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda