When utilizing Vue
and arrow functions in methods, we encounter the issue that arrow functions do not have a this
keyword. The question then arises of how to access data properties such as list
or object
.
export default {
data() {
return {
list: [],
object: {},
}
},
methods: {
onSubmit: (e) => {
//How can access this here?
//Im trying to access this.list
console.log(this);
}
},
}
Your help is much appreciated.