Skip to content

Commit

Permalink
feat: 组件menu的model支持类型Number (#68)
Browse files Browse the repository at this point in the history
* fix: 组件menu支持model类型Number

* docs: menu文档

* feat: menu支持value类型为number,逻辑完善
  • Loading branch information
ocean-gao committed Mar 11, 2022
1 parent 0f24ada commit 5a97901
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/menu/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const MENU_KEY = Symbol('FMenu');
export const MENU_PROPS = {
// 当前选中的值
modelValue: {
type: String,
type: [String, Number],
},
// 垂直或者水平
mode: {
Expand Down
4 changes: 2 additions & 2 deletions components/menu/interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Ref, VNodeChild } from 'vue';

export interface MenuOption {
value: string;
value: string | number;
label: string | (() => VNodeChild);
icon: () => VNodeChild;
children: MenuOption[];
Expand All @@ -10,7 +10,7 @@ export interface MenuOption {

export interface MenuItemType {
uid: string;
value: string;
value: string | number;
type: string;
children: MenuItemType[];
isOpened: Ref<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineComponent({
},
props: {
value: {
type: String,
type: [String, Number],
required: true,
},
label: String,
Expand Down
2 changes: 1 addition & 1 deletion components/menu/subMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineComponent({
},
props: {
value: {
type: String,
type: [String, Number],
default: null,
},
label: String,
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/components/menu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ app.use(FMenu);

| 属性 | 说明 | 类型 | 默认值 |
| ------------------- | ---------------------------------------------------- | ------- | ------------ |
| modelValue(v-model) | 当前选中菜单标识符 | string | `null` |
| modelValue(v-model) | 当前选中菜单标识符 | string / number | `null` |
| mode | 模式,可选值有`horizontal``vertical` | string | `horizontal` |
| collapsed | 是否水平折叠收起菜单(仅在 mode 为 vertical 时可用) | boolean | `false` |
| inverted | 是否反转样式 | boolean | `false` |
Expand Down
7 changes: 5 additions & 2 deletions docs/.vitepress/components/menu/options.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<template>
<f-menu :options="options"></f-menu>
<f-menu v-model="value" :options="options"></f-menu>
</template>
<script>
import { ref, h } from 'vue';
// eslint-disable-next-line import/no-unresolved
import { AppstoreOutlined } from '@fesjs/fes-design/icon';
export default {
setup() {
const value = ref(2);
const options = [
{
label: () => '我是子菜单',
Expand Down Expand Up @@ -57,14 +59,15 @@ export default {
},
{
label: '人群管理',
value: '2',
value: 2,
},
{
label: '资源管理',
value: '3',
},
];
return {
value,
options,
};
},
Expand Down

0 comments on commit 5a97901

Please sign in to comment.