'Error in mounted hook: "ReferenceError: _that is not defined"

i use the ganja.js in my project i pasted the code into the <script> tag of the html file, it works. but when i paste the same code in the mounted() of vue, it gaves a error as the title

  mounted() {
    Algebra(2,0,1,()=>{
      var line = (a,b,c)=>a*1e1 + b*1e2 + c*1e0;
      var point = (x,y)=>!(1e0 + x*1e1 + y*1e2);
      var A = point(-1, -1), B = point(-1, 1), C = point(1, 1);
      var L = line(1, 1, -0.5)
      var M = ()=>C & A;
      var D = ()=>L ^ M;
      let container = document.getElementById('container');
      console.log(this);
      container.appendChild(this.graph([
        "Drag A,B,C",   // First label is used as title.
        0xD0FFE1,       // Numbers are colors - use hex!
        [A,B,C],        // render polygon ABC.
        0x882288,       // Set the color to purple.
        [B,C],          // Render line segment from B to C.
        0x00AA88,       // Medium green.
        L, "L", M, "M", // Render and label lines.
        0x224488,       // Set color blue.
        D, "D",         // Intersection point of L and M
        0x008844,       // Set darker green
        A, "A",         // Render point A and label it.
        B, "B",         // Render point B and label it.
        C, "C",         // Render point C and label it.
      ],{
        grid        : true, // Display a grid
        labels      : true, // Label the grid
        lineWidth   : 3,    // Custom lineWidth (default=1)
        pointRadius : 1,    // Custon point radius (default=1)
        fontSize    : 1,    // Custom font size (default=1)
        scale       : 1,    // Custom scale (default=1), mousewheel.
      }));
    });
  }

The reason for the error is the use of "this.grpah", when i print "this" in console, the error is also raised. And i print "this" in html file, it works. The output result is as follows:

class Element extends generator{
// constructor - create a floating point array with the correct number of coefficients.
  constructor(a) { super(a); if (this.upgrade) this.upgrade(); return this…

How can I use "this" in the arrow function as a parameter of Algebra() in the Vue? Any advise on this would be much appreciated. Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source