Skip to content

Commit 89c3a56

Browse files
committed
docs: update demo
1 parent c47582a commit 89c3a56

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

components/menu/demo/SubMenu.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template functional>
22
<a-sub-menu
3-
:key="data.key"
4-
v-on="listeners"
3+
:key="props.menuInfo.key"
54
>
65
<span slot="title">
76
<a-icon type="mail" /><span>{{ props.menuInfo.title }}</span>

components/menu/demo/SubMenu1.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<a-sub-menu
3+
:key="menuInfo.key"
4+
v-bind="$props"
5+
v-on="$listeners"
6+
>
7+
<span slot="title">
8+
<a-icon type="mail" /><span>{{ menuInfo.title }}</span>
9+
</span>
10+
<template v-for="item in menuInfo.children">
11+
<a-menu-item
12+
v-if="!item.children"
13+
:key="item.key"
14+
>
15+
<a-icon type="pie-chart" />
16+
<span>{{ item.title }}</span>
17+
</a-menu-item>
18+
<sub-menu
19+
v-else
20+
:key="item.key"
21+
:menu-info="item"
22+
/>
23+
</template>
24+
</a-sub-menu>
25+
</template>
26+
<script>
27+
import { Menu } from 'ant-design-vue';
28+
export default {
29+
name: 'SubMenu',
30+
// must add isSubMenu: true
31+
isSubMenu: true,
32+
props: {
33+
...Menu.SubMenu.props,
34+
// Cannot overlap with properties within Menu.SubMenu.props
35+
menuInfo: {
36+
type: Object,
37+
default: ()=>({}),
38+
},
39+
},
40+
};
41+
</script>

components/menu/demo/template.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<cn>
22
#### 单文件递归菜单
33
使用单文件方式递归生成菜单。
4-
因组件内部会动态更改`a-sub-menu`的属性,如果拆分成单文件,无法将属性挂载到`a-sub-menu`上,你需要自行声明属性并挂载。为了实现方便,避免了属性的声明,本示例将其声明为函数式组件,并将所有属性挂载到`a-sub-menu`
4+
因组件内部会动态更改`a-sub-menu`的属性,如果拆分成单文件,无法将属性挂载到`a-sub-menu`上,你需要自行声明属性并挂载。为了方便,避免属性的声明,我们推荐使用函数式组件
55
</cn>
66

77
<us>
88
#### Single file recursive menu
99
Use the single file method to recursively generate menus.
10-
The properties of `a-sub-menu` are dynamically changed inside the component. If you split the file into a single file and you cannot mount the `props` to `a-sub-menu`, you need to declare the `props` and mount it yourself. For the sake of convenience, the declaration of the `props` is avoided. This example declares it as a functional component and mounts all properties to `a-sub-menu`.
10+
The properties of `a-sub-menu` are dynamically changed inside the component. If you split the file into a single file and you cannot mount the `props` to `a-sub-menu`, you need to declare the `props` and mount it yourself. For convenience, to avoid the declaration of attributes, we recommend using functional components.
1111
</us>
1212

1313
```html
@@ -35,7 +35,10 @@ The properties of `a-sub-menu` are dynamically changed inside the component. If
3535
</template>
3636

3737
<script>
38-
/* SubMenu.vue https://github.com/vueComponent/ant-design-vue/blob/master/components/menu/demo/SubMenu.vue */
38+
/*
39+
* recommend SubMenu.vue https://github.com/vueComponent/ant-design-vue/blob/master/components/menu/demo/SubMenu.vue
40+
* SubMenu1.vue https://github.com/vueComponent/ant-design-vue/blob/master/components/menu/demo/SubMenu1.vue
41+
* */
3942
import SubMenu from './SubMenu'
4043
export default {
4144
components: {

components/vc-menu/SubMenu.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const SubMenu = {
4848
triggerSubMenuAction: PropTypes.string,
4949
popupClassName: PropTypes.string,
5050
getPopupContainer: PropTypes.func,
51-
test: PropTypes.any,
5251
forceSubMenuRender: PropTypes.bool,
5352
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
5453
disabled: PropTypes.bool,

0 commit comments

Comments
 (0)