0.1.0-alpha.10 • Published 8 months ago

ff-element v0.1.0-alpha.10

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

包含左侧菜单可伸缩顶部叶子菜单的菜单组件

使用方式 main.js 引用 文件放置 views 文件中

npm install ff-element import menuMain from 'ff-element' Vue.use(menuMain)

创建自己的主组件

menu-man Attributes 菜单数据格式

参数说明类型可选值默认值
menuHeaderName菜单左侧顶部标题String
welcomePath开启初始化首页路由,不展示在左侧菜单中,菜单meta增加String
slot菜单顶部右侧插槽headTitle

例句 views/layout/index.vue

<menuMain :menuHeaderName="'视频云平台'" :welcomePath="'/index/firstHome'">
    <template slot="headTitle">
    </template>
  </menuMain>
</template>

创建菜单配置 router/index.js(main.js 引用的文件)

import mainRouter from 'ff-element/lib/router/router' //创建主路由对象
const $mainRouter = mainRouter(VueRouter, Vue,option)
参数说明类型可选值默认值
VueRouter路由Vue
VuevueVue
option主应用配置Object见下文

option 参数

参数说明类型可选值默认值
url主应用路由字段String
name主应用名称字段String
path主应用文件路径 字段String
component主应用文件引用真实路径字段file

路由 mainRouter 事件

  $mainRouter.getRoutes(menu,config)
参数说明类型可选值默认值
getRoutes获取主应用路由{}见下文

getRoutes 参数

参数说明类型可选值默认值
menu菜单数据{}详见 option 参数
config菜单数据动态Object见下文

config 参数

参数说明类型可选值默认值
label菜单名称Stringname
path菜单路径字段Stingpath
icon菜单图标css 选择器/图片路径icon
children菜单子节点字段Arraychildren
meta菜单额外字段Object详见下文 meta 参数meta
component菜单具体路径字段filecomponent

路由具体配置例句

const $mainRouter = new mainRouter(VueRouter, Vue, {
  url: "/index",
  name: "/index",
  path: "/iframe/index",
  component: (resolve) => require([`@/views/layout/index.vue`], resolve),
});
let array = [].concat(staticRouter.childrenRouter, [])
const routes: Array<RouteConfig> = [
  ...staticRouter.mainRouter,
  ...$mainRouter.getRoutes(array, {
        label: 'label',
    }), //传静态菜单数据
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});

菜单具体数据

参数说明类型可选值默认值
pathqiankun 子应用路由地址String
meta是否为静态路由以及 qiankun 路由Object见下文
name菜单名称String
icon菜单图标字体图标/图片的具体地址/图片 base64
path菜单路径String
component菜单组件路径不可为空 (微前端不可填写)
children子节点(参数与该表格一致) 该字段不能忽略Array

meta 参数

参数说明类型可选值默认值
isMicro是否为微前端路由Boolentrue/false
isStatic是否为静态前端路由Boolentrue/false
isHidden是否展示在菜单中Boolentrue/false

菜单具体数据格式

const childrenRouter: any = [
    {
        path: '/app-vue',
        label: '子应用2',
        meta: {
            isMicro: true,
        },
        children: [],
    },
    {
        path: '/workbench/index',
        label: '工作台',
        component: (resolve) => require([`@e/views/workbench/index.vue`], resolve),
        children: [
            {
                path: '/notice/index',
                label: '代办',
                meta: {
                    isHidden: true,
                },
                component: (resolve) => require([`@e/views/notice/index.vue`], resolve),
                children: [
                    {
                        path: '/site/index',
                        meta: {
                            isHidden: true,
                        },
                        component: (resolve) => require([`@e/views/site/index.vue`], resolve),
                        label: '站点跳转',
                        children: [],
                    },
                ],
            },
        ],
    },
]
const mainRouter = [
    {
        path: '/',
        name: 'login',
        component: (resolve) => require(['@e/views//login/index.vue'], resolve),
    },
]
export default {
    mainRouter: mainRouter,
    childrenRouter: childrenRouter,
}

项目路由文件例句

import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import menu from '@/views/iframe/api/menu.js' //菜单动态数据
import staticRouter from './staticRouter' //菜单静态路由
Vue.use(VueRouter)
const $mainRouter = new mainRouter(VueRouter, Vue, {
  url: "/index",
  name: "/index",
  path: "/layout/index",
  component: (resolve) => require([`@/views/layout/index.vue`], resolve),
});
let array = [].concat(staticRouter.childrenRouter, [])
const routes: Array<RouteConfig> = [
  ...staticRouter.mainRouter,
  ...$mainRouter.getRoutes(array, {
        label: 'label',
    }), //传静态菜单数据
];

const router = new VueRouter({
mode: 'hash',
base: process.env.BASE_URL,
routes,
})

export default router

菜单顶部右侧额外数据

<menuMain :menuHeaderName="'视频云平台'">
        <template slot="headTitle">
            <span class="sc_head-title">欢迎</span>
        </template>
    </menuMain>
<script lang="ts">
</script>
0.1.0-alpha.10

8 months ago

0.1.0-alpha.9

10 months ago

0.1.0-alpha.8

11 months ago

0.1.0-alpha.7

11 months ago

0.1.0-alpha.6

12 months ago

0.1.0-alpha.5

1 year ago

0.1.0-alpha.4

1 year ago

0.1.0-alpha.1

1 year ago

0.1.0-alpha.2

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.4-beta

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago