Home > Enterprise >  Quasar Dialog API App Routing not working properly. Getting "Uncaught TypeError: router.push is
Quasar Dialog API App Routing not working properly. Getting "Uncaught TypeError: router.push is

Time:09-27

I am currently working on a project using Vue 3, Quasar and Firebase. I have a Custom Dialog component that I'm using through Quasar's Dialog API:

<template>
  <q-dialog ref="dialogRef" @hide="onDialogHide" v-on:keyup.enter="onOKClick">
    <q-card >
      <q-card-section >
        <p >{{ this.message }}</p>
      </q-card-section>
      <q-card-actions align="center">
        <q-btn
          
          color="secondary"
          label="OK"
          @click="onOKClick"
        />
        <q-btn
          
          color="negative"
          label="Cancelar"
          @click="onDialogCancel"
        />
      </q-card-actions>
    </q-card>
  </q-dialog>
</template>

<script setup>
import { useDialogPluginComponent } from "quasar";
import { useRouter } from "vue-router";

const props = defineProps({
  title: {
    type: String,
    default: "",
  },
  message: {
    type: String,
    default: "",
  },
});

defineEmits([...useDialogPluginComponent.emits]);

const router = useRouter;

const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
  useDialogPluginComponent();

function onOKClick() {
  onDialogOK();

  router.push({
    name: "home",
  });
}
</script>

What I am trying to achieve is for the dialog to close and the user to be redirected to the Home page once he clicks OK. Console is throwing "Uncaught TypeError: router.push is not a function"

Anyone who knows their way around Quasar's Dialog API who could point me in the right direction would be much appreciated.

CodePudding user response:

Try to execute useRouter function:

const router = useRouter();
  • Related