奶茶精Gaaa 2024-05-31 19:51 采纳率: 47.4%
浏览 1

为什么test1的内容没有显示在面板上

为什么test1的内容没有显示在面板上
预期效果

img

实际效果

img


代码:

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard'  ,affix:true }
    }]
  },

  {
    path: '/sys',
    component: Layout,
    redirect: '/sys/user',
    name: 'sysManage',
    meta: { title: '系统管理', icon: 'sys' },
    children: [
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/sys/user'),
        meta: { title: '用户管理', icon: 'userManage' }
      },
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/sys/role'),
        meta: { title: '角色管理', icon: 'roleManage' }
      }
    ]
  },
  {
    path: '/test',
    component: Layout,
    redirect: '/test/test1',
    name: 'test',
    meta: { title: '测试模块', icon: 'form' },
    children: [
      {
        path: 'test1',
        name: 'test1',
        component: () => import('@/views/test/test1'),
        meta: { title: '功能点1', icon: 'form' }
      },
      {
        path: 'test2',
        name: 'test2',
        component: () => import('@/views/test/test2'),
        meta: { title: '功能点2', icon: 'form' }
      },
      {
        path: 'test3',
        name: 'test3',
        component: () => import('@/views/test/test3'),
        meta: { title: '功能点3', icon: 'form' }
      },

  
    ]
  },
  // 发布动态-首页-朋友动态-发布动态
  {
    path: '/post',
    component: Layout,
    redirect: '/post/shouye',
    name: 'post',
    meta: { title: '动态模块', icon: 'form' },
    children: [
      {
        path: 'shouye',
        name: 'shouye',
        component: () => import('@/views/post/shouye'),
        meta: { title: '首页', icon: 'form' }
      },
      {
        path: 'friendpost',
        name: 'friendpost',
        component: () => import('@/views/post/friendpost'),
        meta: { title: '朋友动态', icon: 'form' }
      },
      {
        path: 'publishpost',
        name: 'publishpost',
        component: () => import('@/views/post/publishpost'),
        meta: { title: '发布动态', icon: 'form' }
      },
  
    ]
  },
  {
    path: '/message',
    component: Layout,
    redirect: '/message',
    children: [{
      path: 'message',
      name: 'message',
      component: () => import('@/views/message/index'),
      meta: { title: '消息通知', icon: 'form'  ,affix:false }
    }]
  },
// mypost页面
{
  path: '/mypost',
  component: Layout,
  redirect: '/mypost',
  children: [{
    path: 'mypost',
    name: 'mypost',
    component: () => import('@/views/mypost/index'),
    meta: { title: '我的主页', icon: 'form'  ,affix:false }
  }]
},
// 消息通知


  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
<template>
  <div>功能点1</div>
</template>

<script>
export default {

}
</script>

<style>

</style>


  • 写回答

2条回答 默认 最新

  • 阿里嘎多学长 2024-05-31 19:51
    关注

    以下内容由CHATGPT及阿里嘎多学长共同生成、有用望采纳:


    根据你提供的代码和图片信息,我们可以从以下几个方面来分析为什么 test1 的内容没有显示在面板上:

    1. 路由配置

      • 从你的路由配置文件来看,test1 的路由配置是正确的,它应该被渲染在 Layout 组件中,并且有一个重定向到 test1 的设置。
    2. 组件导入和注册

      • 你的路由配置中使用了动态导入的方式来导入 test1 组件,这是没有问题的。但是,你需要确保 @/views/test/test1 路径下的组件文件存在,并且能够被正确导入。
    3. 面板的实现代码

      • 你需要查看负责渲染侧边栏面板的 Vue 组件代码,确保 test1 的路由信息被正确添加到了面板的渲染列表中。通常,这涉及到一个与路由守卫相关的 Vuex store 或者是一个全局状态管理。
    4. 权限和角色控制

      • 检查 meta 字段中的 roles 是否正确设置,以及当前用户的角色是否包含在 roles 数组中。如果 roles 设置不正确,可能会导致某些用户看不到 test1
    5. 面包屑和菜单的显示

      • 检查 meta 字段中的 breadcrumbaffix 是否设置正确。如果 breadcrumb 设置为 false,则该路由不会在面包屑导航中显示。affix 属性用于固定菜单项,如果设置为 false,则可能不会在侧边栏固定显示。
    6. Vue Router 的视图渲染

      • 确保 Layout 组件中有 <router-view></router-view> 标签,用于渲染 Vue Router 的视图。
    7. 检查控制台和网络请求

      • 打开浏览器的开发者工具,查看控制台是否有错误信息。同时,检查网络请求是否成功加载了 test1 组件的相关资源。
    8. 查看面板的CSS样式

      • 有时候,即使组件渲染了,但是由于CSS样式的问题,它可能不可见。检查 test1 组件的样式,确保它没有被隐藏或者被其他元素遮挡。

    如果你需要进一步的帮助,你可以提供 test1 组件的代码,以及负责渲染侧边栏面板的 Vue 组件代码。这样我可以更具体地帮助你分析问题。

    至于参考资料,你可以查看 Vue Router 的官方文档,特别是关于 路由配置导航守卫 的部分。此外,Vue.js 的官方文档也是一个很好的资源,特别是关于 组件动态导入 的章节。

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 5月31日

悬赏问题

  • ¥20 有偿:在ubuntu上安装arduino以及其常用库文件。
  • ¥15 请问用arcgis处理一些数据和图形,通常里面有一个根据点划泰森多边形的命令,直接划的弊端是只能执行一个完整的边界,但是我们有时候会用到需要在有很多边界内利用点来执行划泰森多边形的命令
  • ¥30 在wave2foam中执行setWaveField时遇到了如下的浮点异常问题,请问该如何解决呢?
  • ¥20 看图片)删除这个自动化录屏脚本就一直报错找不到脚本文件,如何解决?(相关搜索:bat文件)
  • ¥750 关于一道数论方面的问题,求解答!(关键词-数学方法)
  • ¥200 csgo2的viewmatrix值是否还有别的获取方式
  • ¥15 Stable Diffusion,用Ebsynth utility在视频选帧图重绘,第一步报错,蒙版和帧图没法生成,怎么处理啊
  • ¥15 请把下列每一行代码完整地读懂并注释出来
  • ¥15 pycharm运行main文件,显示没有conda环境
  • ¥15 寻找公式识别开发,自动识别整页文档、图像公式的软件