Fix router initialization in eventhandler
useRouter has to be called in setup or returns undefined otherwise. See https://github.com/vuejs/vue-router/issues/3379
This commit is contained in:
@ -5,6 +5,7 @@ import { useSessionStore } from "../stores/session";
|
||||
|
||||
const error = ref("");
|
||||
const login = ref({ user: "", password: "" });
|
||||
const router = useRouter(); // has to be called in setup
|
||||
|
||||
onMounted(() => {
|
||||
useSessionStore().setTitle("Login");
|
||||
@ -15,7 +16,8 @@ function formSubmit(e: MouseEvent) {
|
||||
useSessionStore().login(login.value)
|
||||
.then(x => {
|
||||
error.value = "";
|
||||
useRouter().replace("/dashboard");
|
||||
router.replace("/dashboard");
|
||||
return x;
|
||||
})
|
||||
.catch(x => error.value = "The entered credentials are invalid!");
|
||||
|
||||
|
Reference in New Issue
Block a user