When does re-rendering happen exactly in vue?

I understand that Vue will redraw when the data changes. But when I change the data in the hook function, for example mounted

, the page doesn't re-render. Below is a portion of my code.

 mounted: function () {
  document.getElementById('lanchange').onclick = function (e) {
    this.loginPopActive = false
    this.lanPopActive = false
    console.log(this.lanPopActive)
  }
}

      

+3


source to share


1 answer


There is a problem in the code with this

. Use the arrow function, close or bind

.



mounted: function () {
  document.getElementById('lanchange').onclick = (e) = >{
    this.loginPopActive = false
    this.lanPopActive = false
    console.log(this.lanPopActive)
  }
}

      

+1


source







All Articles