[Vuejs]-How to use VueCompositionAPI with Vue 3?

1👍

Look, vue 2 is build on the options API.
Vue 3 is build on composition API.

In order to use composition API in your Vue 2 app, you needed the @vue/composition-api package to run it.

What you did is: You upgraded to 3 (wich is by default composition API) and try to use the @vue/composition-api wich is only made for vue 2 in order to use the composition API. But vue 3 is by default composition API. I hope you get me here.

Also, since 2.7 you dont even need this package anymore

Also there is a note:

When you migrate to Vue 3, just replacing @vue/composition-api to vue
and your code should just work.

In vue 2.x you did:

const { ref, reactive } = VueCompositionAPI

In vue 3.x you do:

import { ref, reactive } from "vue"

or:

const { ref, reactive } = Vue;

Leave a comment