使用 Treeview 的主动导航不起作用! - 惯性 Laravel Vue

Active Navigation with Treeview Doesnt Work! - InertiaJS Laravel Vue

我已经有几天没有遇到这种异常了,但它很不可理解......所以我试图将这个问题推到Whosebug,所以当我用treeview点击侧边栏时它没有改变,即使我做了与在 jetstream 和 pingcrm 上所做的相同的事情,这是发生的异常情况

anomalous form

布局中的代码

<sub-nav :active="route().current('admin.a') || route().current('admin.b') || route().current('admin.c')">
    <template #main>
                        <span class="flex items-center">
                            <!-- svg -->
                            <span class="mx-2 font-medium">Api Manager</span>
                        </span>
                    </template>

    <template #content>
                        <sub-nav-link :href="route('admin.a')"
                                      :active="route().current('admin.a') || route().current('admin.api.maps.b')"
                        >
                            Mapper
                        </sub-nav-link>
    
                        <sub-nav-link :href="route('admin.c')"
                                      :active="route().current('admin.c')"
                        >
                            Get Services
                        </sub-nav-link>
                    </template>

</sub-nav>

代码子导航

<template>
    <div class="relative">
        <button @click="openSubNav = !openSubNav" :class="dropdown_classes">
            <slot name="main"></slot>
            <span>
                <svg :class="{'rotate-90': openSubNav, 'rotate-0': !openSubNav}"
                     class="inline-flex w-4 h-4 mt-1 ml-1 transition-transform duration-200 transform md:-mt-1"
                     viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M9 5L16 12L9 19" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                          stroke-linejoin="round"></path>
                </svg>
            </span>
        </button>

        <div v-show="openSubNav" class="bg-gray-200">
            <slot name="content"></slot>
        </div>
    </div>
</template>

<script>
import SubNavLink from "@/Layouts/Admin/Components/SubNavLink"

export default {
    name: "SubNav",
    components: {SubNavLink},
    props: {
        active: {
            type: Boolean,
            default() {
                return false
            }
        },
    },

    data() {
        return {
            openSubNav: this.active ? true : false,
        }
    },

    computed: {
        dropdown_classes() {
            return this.active
                ? 'flex justify-between items-center w-full cursor-pointer py-3 px-6 hover:bg-main-500 hover:text-white border-r-4 border-main-300 focus:outline-none'
                : 'flex justify-between items-center w-full cursor-pointer py-3 px-6 hover:bg-main-500 hover:text-white focus:outline-none border-l-4 border-gray-100'
        }
    }
}
</script>

代码子导航link

<template>
    <inertia-link :href="href" 
                  :class="classes"
                  class="py-2 px-16 block text-sm"
    >
        <slot></slot>
    </inertia-link>
</template>

<script>
export default {
    name: "SubNavLink",
    props: {
        href: String,
        
        active: {
            type: Boolean,
            default() {
                return false
            }
        },
    },
    
    data() {
        return {
            hasActive: false,
        }
    },
    
    computed: {
        classes() {
            return this.active
                ? 'text-gray-100 bg-main-500 ytext-white'
                : 'hover:bg-main-500 hover:text-white'
        }
    },
    
    
}
</script>

谢谢

太好了,我找到了解决这个问题的方法,你可以找到 there