Laravel+Vue+Inertia生产环境动态菜单无法显示问题求助
Laravel+VueJS+InertiaJS生产环境导航菜单不显示问题
问题描述
我基于Laravel、VueJS、InertiaJS开发的网站部署至托管服务器后,出现导航菜单不显示的问题。本地开发模式下功能完全正常,但生产环境中菜单无法加载,已开启app_debug=true却未出现任何报错信息。
菜单视图代码
<li :class="{ 'current' : $page.props.route === 'Home'}"> <Link href="/">Home</Link> </li> <li v-for="(item_parent, index) in $page.props.menu" :key="index" :class="item_parent.child === null ? { 'current': $page.url.startsWith(`/page/${ item_parent.link }`) }:`dropdown `"> <Link :href="item_parent.static_page === 1 ? `/page/${ item_parent.link }`: `${ item_parent.link }`" v-if="item_parent.static_page === 0">{{ item_parent.menu_name }}</Link> <Link :href="item_parent.child === null ? `/page/${ item_parent.link }`:`#`" v-if="item_parent.static_page === 1">{{ item_parent.menu_name }}</Link> <ul> <li v-for="(item_child, index) in item_parent.child" :key="index"> <Link :href="item_child.static_page === 1 ? `/page/${ item_child.link }` : `/${ item_child.link }`"> {{ item_child.menu_name }}</Link> </li> </ul> </li> <li :class="{ 'current': $page.url.startsWith('/download') }"> <Link href="/download">Download</Link> </li>
控制器获取菜单数据代码
$parent = Menu::where('active', 1)->where('parent_id', 0)->orderBy('order', 'ASC')->get(); foreach ($parent as $key_parent => $item_parent){ $this->menu[$key_parent] = array ("parent_id" => $item_parent->parent_id, "menu_name" => $item_parent->menu_name, "link" => $item_parent->link, "static_page" => $item_parent->static_page); $this->menu[$key_parent]['child'] = null; $child = Menu::where('active', 1)->where('parent_id', $item_parent->id)->orderBy('order', 'ASC')->get(); if(!$child->isEmpty()){ foreach ($child as $key_child => $item_child){ $this->menu[$key_parent]['child'][$key_child] = array ("parent_id" => $item_child->parent_id, "menu_name" => $item_child->menu_name, "link" => $item_child->link, "static_page" => $item_child->static_page); } } } return Inertia::render('Frontend/Home', [ 'menu' => $this->menu, ]);
相关截图
菜单表数据库结构

本地环境菜单显示正常

生产环境菜单不显示


菜单数据打印结果

内容的提问来源于stack exchange,提问作者ASHafizullah
相关产品推荐
相关产品推荐

