I'm new in Vue and I'm trying to change this.data using a function.
App.vue:
data () {
return {
data: null
}
},
beforeMount: async function () {
function something (response) {
this.data = response
}
something('hello')
console.log(this.data)
}
Error:
Cannot read property 'data' of null
thisis being bounded when you define the function like that. try defining the function asconst something = (response) => {}instead and see if that fixes it.