After implementing the following code successfully, we noticed that changing the language updates the text correctly thanks to the ref
:
const mainNavigationLinks = computed(() => [
{ label: context.root.$t('navigationMenu.home') },
{ label: context.root.$t('navigationMenu.tickets') },
])
return {
mainNavigationLinks,
}
However, our ideal scenario would involve having mainNavigationLinks
as a reactive
object. This way, we could dynamically add or remove items from the array and have Vue components updated accordingly with the correct translations using the ref
within the array
. The Vue docs indicate that this should be achievable.
Upon trying the code below, we encountered an issue where the label is no longer reactive:
const mainNavigation = reactive([
{ label: context.root.$t('navigationMenu.home') },
{ label: context.root.$t('navigationMenu.tickets') },
])
const mainNavigationLinks = computed(() => mainNavigation)
We are puzzled about what might be missing here. How can we make sure that adding items to the array keeps it reactive? Your insights would be greatly appreciated. Thank you!