[Vuejs]-How do i call a function defined in 'methods' in setup?

0👍

You’re using both Composition API and Options API here? Keep one (CAPI if possible) and after a function declaration like this

<script setup>
function doCoolStuff() {
  doIt()
}

watch(variable, (currentValue, oldValue) => {
  doCoolStuff()
})
</script>

The this keyword is an Options API thing so it will not be available in CAPI (cannot be called inside of setup).

Leave a comment