Functions written in mounted in vue will make an error when switching from the current page to another page. And the timer was cleared.

The function written in mounted in

vue will make an error when switching from the current page to another page.

paint () {
  var canvas = document.querySelector("canvas")
  var width = canvas.width
  var height = canvas.height
  var ctx = canvas.getContext("2d")
  var rotation = 0
  this.paintd3()
  // 
  this.intervalId = setInterval(() => {
    console.log("hahahahhah")
    this.paintd3()
    ctx.save()
    ctx.setTransform(1, 0, 0, 1, 0, 0)
    ctx.translate(0 + 0.5 * 960, 0 + 0.5 * 960)
    ctx.rotate(rotation * Math.PI / 180)
    console.log(rotation * Math.PI / 180)
    ctx.drawImage(canvas, -0.5 * width / 2, -0.5 * height / 2)
    // myChart.clear()
    ctx.restore()
    rotationPP
  }, 1500)
}

clipboard.png

I don"t know why

Mar.20,2021

Hello, how is this problem solved? I have encountered the same problem.

Menu