Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
01b5cf53
Commit
01b5cf53
authored
Oct 11, 2016
by
baiyaaaaa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix menu auto collapse after router change
parent
42921e24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
packages/menu/src/menu.vue
packages/menu/src/menu.vue
+21
-23
No files found.
packages/menu/src/menu.vue
View file @
01b5cf53
...
@@ -27,12 +27,7 @@
...
@@ -27,12 +27,7 @@
type
:
String
,
type
:
String
,
default
:
''
default
:
''
},
},
defaultOpeneds
:
{
defaultOpeneds
:
Array
,
type
:
Array
,
default
()
{
return
[];
}
},
theme
:
{
theme
:
{
type
:
String
,
type
:
String
,
default
:
'
light
'
default
:
'
light
'
...
@@ -43,7 +38,7 @@
...
@@ -43,7 +38,7 @@
data
()
{
data
()
{
return
{
return
{
activeIndex
:
this
.
defaultActive
,
activeIndex
:
this
.
defaultActive
,
openedMenus
:
this
.
defaultOpeneds
.
slice
(
0
),
openedMenus
:
(
this
.
defaultOpeneds
||
[])
.
slice
(
0
),
menuItems
:
{},
menuItems
:
{},
submenus
:
{}
submenus
:
{}
};
};
...
@@ -55,14 +50,18 @@
...
@@ -55,14 +50,18 @@
this
.
handleSelect
(
value
,
indexPath
);
this
.
handleSelect
(
value
,
indexPath
);
},
},
defaultOpeneds
(
value
)
{
defaultOpeneds
:
{
this
.
openedMenus
=
value
;
deep
:
true
,
handler
(
value
)
{
this
.
openedMenus
=
value
;
}
}
}
},
},
methods
:
{
methods
:
{
openMenu
(
index
,
indexPath
)
{
openMenu
(
index
,
indexPath
)
{
let
openedMenus
=
this
.
openedMenus
;
let
openedMenus
=
this
.
openedMenus
;
if
(
openedMenus
.
indexOf
(
index
)
!==
-
1
)
return
;
if
(
openedMenus
.
indexOf
(
index
)
!==
-
1
)
return
;
// 将不在该菜单路径下的其余菜单收起
if
(
this
.
uniqueOpened
)
{
if
(
this
.
uniqueOpened
)
{
this
.
openedMenus
=
openedMenus
.
filter
(
index
=>
{
this
.
openedMenus
=
openedMenus
.
filter
(
index
=>
{
return
indexPath
.
indexOf
(
index
)
!==
-
1
;
return
indexPath
.
indexOf
(
index
)
!==
-
1
;
...
@@ -92,29 +91,28 @@
...
@@ -92,29 +91,28 @@
this
.
broadcast
(
'
submenu
'
,
'
item-select
'
,
[
index
,
indexPath
]);
this
.
broadcast
(
'
submenu
'
,
'
item-select
'
,
[
index
,
indexPath
]);
this
.
openedMenus
=
[];
this
.
openedMenus
=
[];
}
else
{
}
else
{
this
.
openActiveItemMenus
();
}
if
(
this
.
router
&&
route
)
{
this
.
$router
.
push
(
route
);
}
},
openActiveItemMenus
()
{
let
index
=
this
.
activeIndex
;
if
(
index
&&
this
.
mode
===
'
vertical
'
)
{
let
indexPath
=
this
.
menuItems
[
index
].
indexPath
;
// 展开该菜单项的路径上所有子菜单
// 展开该菜单项的路径上所有子菜单
indexPath
.
forEach
(
index
=>
{
indexPath
.
forEach
(
index
=>
{
let
submenu
=
this
.
submenus
[
index
];
let
submenu
=
this
.
submenus
[
index
];
submenu
&&
this
.
openMenu
(
index
,
submenu
.
indexPath
);
submenu
&&
this
.
openMenu
(
index
,
submenu
.
indexPath
);
});
});
}
}
if
(
this
.
router
&&
route
)
{
this
.
$router
.
push
(
route
);
}
}
}
},
},
mounted
()
{
mounted
()
{
let
index
=
this
.
activeIndex
;
this
.
openActiveItemMenus
();
if
(
index
&&
this
.
mode
===
'
vertical
'
)
{
let
indexPath
=
this
.
menuItems
[
index
].
indexPath
;
// 展开该菜单项的路径上所有子菜单
indexPath
.
forEach
(
index
=>
{
let
submenu
=
this
.
submenus
[
index
];
submenu
&&
this
.
openMenu
(
index
,
submenu
.
indexPath
);
});
}
}
}
};
};
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment