File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import UserIcon from '../assets/user.png'
99const LevelBasicLayout = defineComponent ( {
1010 name : 'LevelBasicLayout' ,
1111 setup ( ) {
12+ const router = useRouter ( )
13+ const route = useRoute ( )
14+
1215 // 获取显示状态的路由
1316 const menuLists = computed ( ( ) => {
1417 const menus = getMenus ( ) . filter ( ( item : any ) => ! item ?. meta ?. hidden )
@@ -24,9 +27,9 @@ const LevelBasicLayout = defineComponent({
2427 // 获取子路由
2528 const subMenuLists = computed ( ( ) => {
2629 let menus : RouteRecordRaw [ ] = [ ]
27- const names = useRoute ( ) . path . split ( '/' )
30+ const names = route . path . split ( '/' )
2831 if ( names . length ) {
29- getMenus ( ) . forEach ( ( item ) => {
32+ getMenus ( ) . forEach ( ( item : RouteRecordRaw ) => {
3033 if ( item . name == names [ 1 ] ) {
3134 menus = item ?. children || [ ]
3235 }
@@ -38,7 +41,7 @@ const LevelBasicLayout = defineComponent({
3841 // 获取路由列表
3942 const getMenus = ( ) => {
4043 let menuList : RouteRecordRaw [ ] = [ ]
41- const routes : Array < RouteRecordRaw > = useRouter ( ) . options ?. routes || [ ]
44+ const routes : Array < RouteRecordRaw > = router . options ?. routes || [ ]
4245 routes . forEach ( ( item ) => {
4346 if ( item . path == '/' ) {
4447 menuList = item . children || [ ]
You can’t perform that action at this time.
0 commit comments