【问题标题】:Active Navigation with Treeview Doesnt Work! - InertiaJS Laravel Vue使用 Treeview 进行主动导航不起作用! - 惯性JS Laravel Vue
【发布时间】:2021-08-03 01:00:44
【问题描述】:

我已经有几天没有遇到这种异常了,但它非常难以理解......所以我试图将这个问题推送到 stackoverflow,所以当我点击带有 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>

代码子导航链接

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

谢谢

【问题讨论】:

    标签: html laravel vue.js sidebar inertiajs


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-05-30
      • 2019-07-28
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2022-10-14
      • 2017-03-26
      • 2021-06-25
      相关资源
      最近更新 更多