Morgan Hayes
Morgan Hayes

Reputation: 383

Quasar Vue 3 route.push() not a function

When I try to route to another page in js I get the error:

Uncaught TypeError: route.push is not a function

code snippit:

    import { useRoute } from "vue-router";
    const route = useRoute();

    function openApp() {
        route.push("/#/home");
    };

when I use anchor tag around a btn the routing works

<a href="/#/home">
    <q-btn class="q-ma-md" color="primary" icon="check" label="OK" />
</a>

Any Ideas, Thanks

Upvotes: 2

Views: 2182

Answers (1)

Ilijanovic
Ilijanovic

Reputation: 14904

There is a difference between useRoute and useRouter

Try this:

import { useRouter } from "vue-router";
const router = useRouter();
router.push("/#/home");

Upvotes: 5

Related Questions