wuruoyun / vue-component-lib-starter

A bare-bones example of creating your own Vue component library.
313 stars 59 forks source link

Is it possible to use this starter with vue-router? #41

Closed larrasu closed 1 year ago

larrasu commented 1 year ago

Is it possible to use vue-router in this starter? Please check my index.ts below.

import { App } from "vue";
import { router } from "./router/index";
import { pinia } from "./stores";
import Notifications from "notiwind";
import * as components from "./components";
import * as pages from "./pages";

function install(app: App) {
    app.use(router);
    app.use(pinia);
    app.use(Notifications);

    for (const key in components) {
        // @ts-expect-error
        app.component(key, components[key]);
    }
    for (const key in pages) {
        app.component(key, pages);
    }
}

import "./assets/main.css";

export default { install };

export * from "./router";
export * from "./components";
export * from "./pages";
export * from "./utils";
export * from "./stores";

I'm getting a warning: [Vue warn]: injection "Symbol(router)" not found.

When I use useRouter, I'm getting this error: TypeError: Cannot read properties of undefined (reading 'push')