vueblocks / vue-use-utilities

A collection of vue composition-api utilities.
https://vueblocks.github.io/vue-use-utilities/
MIT License
32 stars 7 forks source link

example for vue2 meets a error when getting store from useStore #1

Closed Skeanmy closed 3 years ago

Skeanmy commented 3 years ago
// store is undefined in vue2
const store = useStore()

In vue-demi,getCurrentInstance return a intance of ComponentInternalInstance type

declare interface ComponentInternalInstance {
    uid: number;
    parent: ComponentInternalInstance | null;
    root: ComponentInternalInstance;
    /**
     * Vnode representing this component in its parent's vdom tree
     */
    vnode: VNode;
    /**
     * Root vnode of this component's own vdom tree
     */
    /**
     * The reactive effect for rendering and patching the component. Callable.
     */
    update: Function;
    data: Data;
    props: Data;
    attrs: Data;
    refs: Data;
    emit: EmitFn;
    slots: InternalSlots;
    emitted: Record<string, boolean> | null;
    proxy: ComponentInstance;
    isMounted: boolean;
    isUnmounted: boolean;
    isDeactivated: boolean;
}

$store exists in proxy property,it should be a small omission😊

xiaoluoboding commented 3 years ago

Well, It works half month ago. I notice that @vue/comosition-api is bump up to v1.0.0-beta.22. which the version aim to aligning with Vue 3 in getCurrentInstance function. It had a breaking changes: The internal vm can be accessed with getCurrentInstance().proxy