Browse Source

masger

master
邓宏 3 years ago
parent
commit
b39caa6bf2
  1. 8
      src/layout/components/appMain.vue
  2. 16
      src/layout/components/sidebar/sidebarItem.vue
  3. 10
      src/router/index.js

8
src/layout/components/appMain.vue

@ -3,9 +3,11 @@
</style>
<template>
<transition name="fade-transform" mode="out-in">
<keep-alive :include="cacheViews">
<router-view :key="$route.path"/>
</keep-alive>
<router-view v-slot="{ Component }" :key="$route.path">
<keep-alive :include="cacheViews">
<component :is="Component"/>
</keep-alive>
</router-view>
</transition>
</template>
<script>

16
src/layout/components/sidebar/sidebarItem.vue

@ -65,13 +65,15 @@ export default defineComponent({
}
onMounted(async ()=>{
commit('data/setMenu',{
key:props.basePath,
item:{
name:(await props.item?.component?.())?.default.name,
parentPath:props.item?.meta?.parentPath,
}
})
if(typeof props.item?.component==='function'){
commit('data/setMenu',{
key:props.basePath,
item:{
name:(await props.item.component())?.default?.name,
parentPath:props.item?.meta?.parentPath,
}
})
}
})
return _data;
},

10
src/router/index.js

@ -1,18 +1,14 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout'
import Home from '../views/Home.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
]
export const menu=[
{
path:"/demo",
path:"/",
component: Layout,
redirect:"/path1",
meta:{
title:"demo",
icon:"atm",

Loading…
Cancel
Save