Take a look at the following simple component example in Vue 3:
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Test',
setup(){
return{
one,
two
}
}
})
function one(){
console.log(this) //<-- Proxy{}
two()
}
function two(){
console.log(this) //<-- undefined
}
</script>
<template>
<a href="#" @click.prevent="one()">Start</a>
</template>
I'm trying to understand why this is undefined in the two() function when it's called from the one() function. Both functions are returned in setup(), so I would expect them to both have access to this.
This being said, how do I then get a reference to the component instance of this inside my two() function?
thiswith composition API.