menu.vue
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<div>
<Menu ref="menu" active-name="1-2" :open-names="openNames" theme="dark" accordion @on-open-change="handleOpenChange">
<Submenu name="1">
<template slot="title">
<Icon type="ios-analytics"></Icon>
Navigation One
</template>
<MenuGroup title="Item 1">
<MenuItem name="1-1">Option 1</MenuItem>
<MenuItem name="1-2">Option 2</MenuItem>
</MenuGroup>
<MenuGroup title="Item 2">
<MenuItem name="1-3">Option 3</MenuItem>
<MenuItem name="1-4">Option 4</MenuItem>
</MenuGroup>
</Submenu>
<Submenu name="2">
<template slot="title">
<Icon type="ios-filing"></Icon>
Navigation Two
</template>
<MenuItem name="2-1">Option 5</MenuItem>
<MenuItem name="2-2">Option 6</MenuItem>
<Submenu name="3">
<template slot="title">Submenu</template>
<MenuItem name="3-1">Option 7</MenuItem>
<MenuItem name="3-2">Option 8</MenuItem>
</Submenu>
<Submenu name="4">
<template slot="title">Submenu</template>
<MenuItem name="4-1">Option 7</MenuItem>
<MenuItem name="4-2">Option 8</MenuItem>
</Submenu>
</Submenu>
<Submenu name="5">
<template slot="title">
<Icon type="ios-gear"></Icon>
Navigation Three
</template>
<MenuItem name="5-1">Option 9</MenuItem>
<MenuItem name="5-2">Option 10</MenuItem>
<MenuItem name="5-3">Option 11</MenuItem>
<MenuItem name="5-4">Option 12</MenuItem>
</Submenu>
</Menu>
<Button @click="setOpenNames">修改展开数组</Button>
</div>
</template>
<script>
export default {
data () {
return {
openNames: ['1']
};
},
methods: {
handleOpenChange (name) {
console.log(name)
},
setOpenNames () {
this.openNames = ['2', '3'];
this.$nextTick(() => {
this.$refs.menu.updateOpened();
})
}
}
}
</script>