0👍
✅
Possible Solutions
1.By binding this reference to function
created() {
document.addEventListener('keyup', (function(event) {
if (event.code == 'KeyQ' && (event.ctrlKey || event.metaKey)) {
alert("asdfasdfasfd")
this.clear()
}
}).bind(this))
},
2.use of arrow function
created() {
document.addEventListener('keyup', (event) => {
if (event.code == 'KeyQ' && (event.ctrlKey || event.metaKey)) {
alert("asdfasdfasfd")
this.clear()
}
})
},
Source:stackexchange.com