This is a fork of vue-demi.
The original version intends two use cases:
- Vue2 + composition api
- Vue3
However, this fork removes the composition api. It is useful when your library doesn't use any composition api but still need to check vue version and use different APIs accordingly.
import { isVue3, h } from 'vue-demi';
...
render(createElement) {
return (isVue3 ? h : createElement)(...)
}
In case of Vue 2, this forked vue-demi
will export all the Vue3-only APIs as undefined
, such as h
, createApp
, defineComponent
, and so on.
When to import from vue
and when to import from vue-demi
?
- If you need access to
isVue3
,isVue2
,Vue2
, orversion
, then they all are invue-demi
. - If you need Vue3-only APIs, import them from
vue-demi
along withisVue3
variable. If it's used with Vue3, the APIs will work. If with Vue2, they will beundefined
. - Other than that, keep your imports from
vue
.