1. Dashboard
  2. Forum
    1. Unresolved Threads
  3. Members
    1. Recent Activities
    2. Users Online
    3. Team-Mitglieder
    4. Trophy
    5. Search Members
  4. Lexicon
  • Login
  • Register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Pages
  • Forum
  • Lexikon
  • More Options
  1. Informatik Forum
  2. Webmaster & Internet
  3. Development

Styles werden beim direkten wechsel nicht übernommen

    • TypeScript
    • Problem
  • Syntafin
  • June 5, 2025 at 8:59 PM
  • Thread is Unresolved
  • Syntafin
    27
    Syntafin
    LISTstack Dev
    Reactions Received
    499
    Points
    7,839
    Trophies
    2
    Posts
    1,423
    • June 5, 2025 at 8:59 PM
    • #1

    Ich mal wieder, mit etwas was mich gerade echt.... übelst nervt!

    Um die Navigation (egal ob Mobile oder Desktop) zu vereinheitlichen nutze ich ein Composable das ich einfach lade und darüber iteriere, das sieht auch ganz klein und fein so aus:

    TypeScript
    import {
        HomeIcon,
        NewspaperIcon,
        BuildingOfficeIcon,
        IdentificationIcon,
        PhotoIcon,
        EnvelopeIcon
    } from '@heroicons/vue/24/outline';
    
    export const navigation = [
        { id: 1, name: 'Home', href: route('home'), icon: HomeIcon, current: route().current('home') },
        { id: 2, name: 'News', href: route('post.index'), icon: NewspaperIcon,current: route().current('post.*') },
        { id: 3, name: 'Divisions', href: route('division.index'), icon: BuildingOfficeIcon,current: route().current('division.*') },
        { id: 4, name: 'About us', href: route('aboutus'), icon: IdentificationIcon,current: route().current('aboutus') },
        { id: 5, name: 'Gallery', href: '#', icon: PhotoIcon,current: false },
        { id: 6, name: 'Contact', href: '#', icon: EnvelopeIcon,current: false },
    ];
    Display More

    Das ganze funktioniert ja auch ganz schön dann in der Komponente:

    HTML
    <Link
        v-for="item in navigation"
        :key="item.id"
        :href="item.href"
        :class="[item.current ? 'bg-blue-950 text-white' : 'hover:bg-blue-800', 'inline-flex flex-col items-center text-xl font-bold rounded px-3 py-3']"
        :aria-current="item.current ? 'page' : undefined"
    >
        <component :is="item.icon" class="size-6" />
        {{ item.name }}
    </Link>

    Jetzt aber das Problem: Wechsle ich dann die Seite, wird der Current State nicht gesetzt, um das zu verdeutlichen, hab ich das eben fix mal aufgenommen als Video:

    External Content www.youtube.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.


    Damit die "neue" Seite auch in der Navigation als aktuelle highlighted ist, muss ich erst alles neu laden, nicht der Sinn der Sache. Jemand vielleicht hier eine Idee wo eventuell mein Denkfehler ist?

    Als Info natürlich vergessen: Die route() funktion wird durch Ziggy bereitgestellt, ob das Problem auch mit Wayfinder besteht werde ich erst Sonntag Abend/Montag ausprobieren können.

    A red dragon falls from the heavens... Ah, that memory has been lost. A shame. It was a favorite of mine...

  • Testie
    1
    Testie
    Mitglied
    Points
    5
    Posts
    1
    • June 8, 2025 at 3:01 AM
    • #2

    Hallo, sieht nach einem Zeitproblem aus. Zum Zeitpunkt wo die navi in TS geladen wird, ist wohl im Router current noch nicht gesetzt.
    Schwer zu sagen wenn man nicht alle Projektdateien kennt.

    Viele Grüße

  • Syntafin
    27
    Syntafin
    LISTstack Dev
    Reactions Received
    499
    Points
    7,839
    Trophies
    2
    Posts
    1,423
    • June 8, 2025 at 11:09 AM
    • #3
    Quote from Testie

    Schwer zu sagen wenn man nicht alle Projektdateien kennt.

    Was fehlt dir denn?

    A red dragon falls from the heavens... Ah, that memory has been lost. A shame. It was a favorite of mine...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!

Register Yourself Login

Tags

  • typescript
  • VueJS
  • ziggy

Rechtliches

Impressum

Datenschutzerklärung