0.0.2 • Published 4 years ago

reactive-navigation-bar v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

reactive-navigation-bar

a reactive navigation bar component that's based on element-ui. IE compatible

Install

npm install reactive-navigation-bar -S

Quick Start

import Vue from 'vue'
import ReactiveNavigationBar from 'reactive-navigation-bar'
# Vue.component('reactive-navigation-bar', ReactiveNavigationBar) # 可以指定组件名称
Vue.use(ReactiveNavigationBar) # 组件名称 `reactive-navigation-bar`

For more information, please refer to ReactiveNavigationBar in our documentation.

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for demo with minification
npm run demo:build

# build for gh-pages with minification
npm run demo:prepublish

# build for production with minification
npm run build

# generate gh-pages
npm run deploy

LICENSE

MIT

截图

截图

基本用法

<template>
  <div class="vd-demo__block vd-demo__block-2">
    <reactive-navigation-bar
      :theme="theme"
      :data="dataList"
      :theme-color="color"
      width="calc(100% - 100px)"
    />
  </div>
</template>
<script>

<script>
  export default {
    data () {
      return {
        theme: 'light',
        dataList: [],
        color: '#1890ff'
      }
    },
    mounted() {
      this.dataList = [
        {
          title: 'Dashboard',
          hide: false,
          path: '1',
          icon: 'el-icon-s-tools',
          children: [
            {
              title: '分析页',
              hide: false,
              icon: 'el-icon-star-off',
              path: '1.1',
              disabled: true
            },
            {
              title: '监控页',
              icon: 'el-icon-s-operation',
              path: '1.2',
              hide: false
            },
            {
              title: '工作台',
              icon: 'el-icon-s-cooperation',
              path: '1.3',
              hide: false
            }
          ]
        },
        {
          title: '表单页',
          hide: false,
          icon: 'el-icon-s-order',
          children: [
            {
              title: '数据管理对象长长长长长长长',
              hide: false,
              path: '2.1',
              children: [{
                title: '数据管理对象长长长长长长长',
                hide: false,
                path: '2.1.1'
              }]
            },
            {
              title: '分步表单',
              hide: false,
              path: '2.2',
              children: [{
                title: '数据管',
                hide: false,
                path: '2.2.1'
              }]
            },
            {
              title: '高级表单',
              hide: false,
              path: '2.3'
            }
          ]
        },
        {
          title: '列表页',
          hide: false,
          path: '3',
          icon: 'el-icon-s-platform'
        },
        {
          title: '搜索列表',
          hide: false,
          path: '4.1',
          icon: 'el-icon-search',
          children: [
            {
              title: '搜索列表(文章)',
              hide: false,
              path: '4.1.1'
            },
            {
              title: '搜索列表(应用)',
              hide: false,
              disabled: true,
              path: '4.1.2'
            },
            {
              title: '搜索列表(项目)',
              hide: false,
              path: '4.1.3'
            }
          ]
        },
        {
          title: '详情页',
          hide: false,
          disabled: true,
          path: '5',
          icon: 'el-icon-s-claim'
        }
      ];
    },

    methods: {
      toggleColor() {
        if (this.color === '#ffd04b') {
          this.color = '#1890ff';
        } else {
          this.color = '#ffd04b';
        }
      },
      toggle() {
        if (this.theme === 'light') {
          this.theme = 'dark';
        } else {
          this.theme = 'light';
        }
      }
    }
  }
</script>

ReactiveNavigationBar props

参数说明类型可选值默认值
data菜单Array--
default-active默认选中项String--
route-mode是否菜单选中只与当前路由route有关Boolean-false
trigger子菜单浮窗触发方法Stringhover, clickhover
theme主题Stringlight, darklight
theme-color主题颜色String-#52c41a
background-color背景颜色String-当主题为light时,默认为#e6f7ff; 当主题为dark时,默认为#24292e
align主菜单排列方式Stringfixed, fluidfluid
width主菜单宽度Number, String--
bar-height主菜单高度Number, String-56
menu-height子菜单高度Number, String-32
arrow是否在主菜单内显示箭头Boolean-true
bar-background-active子菜单选中时是否改变主菜单背景颜色Boolean-false
underline选中时是否有下划线效果Boolean-true
append-to-body悬浮子菜单是否挂载到body上Boolean-true
strict-align子菜单宽度是否对齐主菜单Boolean-true

ReactiveNavigationBar events

事件名称说明回调参数
select菜单被选中时的事件item, index, indexPath, event
open开启子菜单浮窗的事件item, index, indexPath
close关闭子菜单浮窗的事件item, index, indexPath

ReactiveNavigationBar data item prop

名称说明类型可选值默认值
icon图标String--
title标题String--
path路由String--
hide是否隐藏Boolean-false
disabled是否禁用Boolean-false
children子菜单数据ArrayObject-[]
meta辅助性属性(内含index时,index内容与是否选中有关)Object--

更新日志

  • v1.1.1: 路由跳转兼容IE浏览器; 添加routeMode属性,支持纯路由的选中判断