Commit 465f2219 authored by 蔡伟's avatar 蔡伟

Merge branch 'feat/layout-style' into 'dev'

feat(*): 路由跳转问题修改

See merge request !2
parents 9243b184 7a56a91f
......@@ -57,11 +57,11 @@ export default {
if (route.matched && route.matched.length > 0) {
const matchedRoutes = route.matched;
// 添加首页项(可选)
breadcrumbList.value.push({
path: '/dashboard',
meta: { title: '首页' }
});
// // 添加首页项(可选)
// breadcrumbList.value.push({
// path: '/dashboard',
// meta: { title: '首页' }
// });
// 添加匹配的路由
matchedRoutes.forEach(item => {
......
......@@ -16,13 +16,15 @@
<el-icon><location /></el-icon>
<span>{{getMenuTitle(item)}}</span>
</template>
<el-menu-item v-for="(item_son, index_son) in item.children" :key="item_son.path" :index="index + '_' + index_son">
<router-link :to="item.path + '/' + item_son.path">{{getMenuTitle(item_son)}}</router-link>
<el-menu-item v-for="(item_son, index_son) in item.children" :key="item_son.path" :index="index + '_' + index_son"
@click="handleClick(item_son.path)">
<span>{{getMenuTitle(item_son)}}</span>
<!-- <router-link :to="item.path + '/' + item_son.path">{{getMenuTitle(item_son)}}</router-link> -->
</el-menu-item>
</el-sub-menu>
<el-menu-item v-else :index="index + ''" class="submenu-box">
<el-menu-item v-else :index="index + ''" class="submenu-box" @click="handleClick(item.path)">
<el-icon><setting /></el-icon>
<span><router-link :to="item.path">{{getMenuTitle(item)}}</router-link></span>
<span>{{getMenuTitle(item)}}</span>
</el-menu-item>
</template>
</el-menu>
......@@ -38,6 +40,19 @@ import {
Setting,
} from "@element-plus/icons-vue";
import {routes} from "../router/index.js";
import { useRouter } from 'vue-router'
const router = useRouter()
const handleClick = (path) => {
console.log(path);
if (path.startsWith('/')) {
router.push(path) // 绝对路径,直接跳转
} else {
router.push('/' + path) // 相对路径,补全
}
}
const routerList = routes[0].children;
const handleOpen = (key, keyPath) => {
console.log(key, keyPath);
......
import { createWebHistory, createRouter } from 'vue-router'
import Dashboard from '../views/dashboard/index.vue'
import HomeView from '../views/HomeView.vue'
import AboutView from '../views/AboutView.vue'
import User from '../views/user.vue'
......@@ -11,65 +12,49 @@ const routes = [
path: '/',
component: Layout,
children: [
{
path: '/dashboard',
component: AboutView,
meta: {
title: '首页',
},
},
{
path: '/2',
{
path: '/dashboard',
component: Dashboard,
meta: { title: '首页' },
},
{
path: '/overview',
component: HomeView,
meta: { title: '除尘器总览' },
},
{
path: '/device-management',
component: AboutView,
meta: { title: '设备管理' },
},
{
path: '/monitor',
component: AboutView,
meta: { title: '除尘器监控' },
},
{
path: '/alerts',
component: AboutView,
meta: { title: '告警总览' },
},
{
path: '/my-loop',
meta: { title: '我的闭环' },
children: [
{
path: '/my-loop/profile',
component: HomeView,
meta: {
title: '除尘器总览',
},
},
{
path: '/3',
component: AboutView,
meta: {
title: '设备管理',
},
},
{
path: '/4',
meta: { title: '我的待办' },
},
{
path: '/my-loop/posts',
component: AboutView,
meta: {
title: '除尘器监控',
},
},
{
path: '/5',
component: AboutView,
meta: {
title: '告警总览',
},
},
{
path: '/6',
meta: {
title: '我的闭环',
},
children: [
{
path: 'profile',
component: HomeView,
meta: {
title: '我的待办',
},
},
{
path: 'posts',
component: AboutView,
meta: {
title: '我的已办',
},
},
],
},
meta: { title: '我的已办' },
},
]
},
]
},
},
{
path: '/login',
component: Login,
......
<template>
<div class="page-container">
dashborad
</div>
</template>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment