繁体   English   中英

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

[英]Active Navigation with Treeview Doesnt Work! - InertiaJS Laravel Vue

自从我遇到这种异常情况以来已经有几天了,但它非常难以理解......所以我试图将这个问题推送到 stackoverflow,所以当我点击带有 treeview 的侧边栏时,即使我做了同样的事情,它也没有改变是在 jetstream 和 pingcrm 上完成的,这是发生的异常情况

异常形式

布局中的代码

<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>

代码子导航链接

<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>

谢谢

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM