Skip to content

Commit

Permalink
Fix bottom navigation init select (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyakovri authored Aug 12, 2023
1 parent 99b11bf commit ffa4e57
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/IrdomNavbar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import { ref, Ref } from 'vue';
export interface NavbarItem {
name: string;
Expand All @@ -11,18 +11,20 @@ const props = defineProps<{
items: NavbarItem[];
}>();
const findFirstIndexOfStringByPrefix = (arr: NavbarItem[], prefix: string) => {
const findFirstIndexOfStringByPrefix = (arr: NavbarItem[], prefix: string, result: Ref<number | undefined>) => {
arr.forEach((ni, i) => {
ni.path.forEach(p => {
if (prefix.startsWith(p)) {
return i;
result.value = i;
return;
}
});
});
return undefined;
};
const value = ref(findFirstIndexOfStringByPrefix(props.items, window.location.pathname));
const value = ref(undefined);
findFirstIndexOfStringByPrefix(props.items, window.location.pathname, value);
</script>

<template>
Expand Down

0 comments on commit ffa4e57

Please sign in to comment.