Bugfixing a refaktoring
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<q-item
|
||||
clickable
|
||||
:active="isButtonActive"
|
||||
tag="router-link"
|
||||
:to="to"
|
||||
>
|
||||
@@ -19,6 +20,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {computed} from "vue";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
@@ -40,5 +43,17 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const $route = useRoute();
|
||||
const $router = useRouter();
|
||||
const isButtonActive = computed(() => {
|
||||
const btnResolvedPath = $router.resolve(props.to).path;
|
||||
|
||||
if (props.to.name === 'myFlights') {
|
||||
return $route.name.toLowerCase().includes("flight");
|
||||
} else {
|
||||
return $route.fullPath === btnResolvedPath || $route.fullPath.startsWith(btnResolvedPath);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user