Skip to content

Commit 935d9aa

Browse files
authored
fix:[Sidebar]: fixed bug in iOS (PanJiaChen#1152)
1 parent 616f173 commit 935d9aa

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export default {
2+
computed: {
3+
device() {
4+
return this.$store.state.app.device
5+
}
6+
},
7+
mounted() {
8+
// In order to fix the click on menu on the ios device will trigger the mouseeleave bug
9+
// https://github.com/PanJiaChen/vue-element-admin/issues/1135
10+
this.fixBugIniOS()
11+
},
12+
methods: {
13+
fixBugIniOS() {
14+
const $submenu = this.$refs.submenu
15+
if ($submenu) {
16+
const handleMouseleave = $submenu.handleMouseleave
17+
$submenu.handleMouseleave = (e) => {
18+
if (this.device === 'mobile') {
19+
return
20+
}
21+
handleMouseleave(e)
22+
}
23+
}
24+
}
25+
}
26+
}

src/views/layout/components/Sidebar/SidebarItem.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</app-link>
1010
</template>
1111

12-
<el-submenu v-else :index="item.name||item.path">
12+
<el-submenu v-else ref="submenu" :index="item.name||item.path">
1313
<template slot="title">
1414
<item v-if="item.meta" :icon="item.meta.icon" :title="generateTitle(item.meta.title)" />
1515
</template>
@@ -40,10 +40,12 @@ import { generateTitle } from '@/utils/i18n'
4040
import { validateURL } from '@/utils/validate'
4141
import Item from './Item'
4242
import AppLink from './Link'
43+
import FixiOSBug from './FixiOSBug'
4344
4445
export default {
4546
name: 'SidebarItem',
4647
components: { Item, AppLink },
48+
mixins: [FixiOSBug],
4749
props: {
4850
// route object
4951
item: {

0 commit comments

Comments
 (0)