removeventListener nie działa w klasie JavaScript
'use strict'
class Mouser {
constructor () {
this.counter = 0
this.clicked = function (event) {
this.counter ++
console.log('clicks:', this.counter)
if (this.counter >= 10) this.remove()
}
// save the click handler so it can be used in multiple places
this.clickHandler = this.clicked.bind(this);
window.addEventListener('click', this.clickHandler)
}
remove () {
console.log('Removing click listener') // this line runs ..
window.removeEventListener('click', this.clickHandler)
}
}
var mouse = new Mouser()
Gifted Helper