1.0.4-beta.6 • Published 1 year ago

v-side-menu v1.0.4-beta.6

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

v-side-menu

An easy-to-use navigation component powered by Vue.js

view Demo

npm.io

Install

You can use Yarn or NPM

npm install v-side-menu

OR

yarn add v-side-menu

Usage

// Import the components where you need it
import SideMenu from "v-side-menu";
export default {
    components: [SideMenu]
}

Props

NameTypeDefaultDescription
menuListArray[]Menu List,A two-dimensional array, each array is listed from left to right
collectionListArray[]Collection list
historyListArray[]Recent Access List
collectionBooleantrueWhether to display my collection
historyBooleantrueWhether to show recent visits
searchBooleantrueWhether to display search
showDrawerBooleanfalseDrawer switch
drawerWidthString'1000px'Drawer width
drawerPlacementString'left'Drawer pull out direction
drawerTopString'0px'Distance between drawer and top
drawerTitleString''Drawer title
closableBooleantrueWhether to display the close button
maskBooleantrueWhether to display the mask
maskClosableBooleantrueClick to close the mask
innerBooleanfalseWhether to open in the parent element
btnStyleObject{}Customize the default menu button style

Events

NameParametersDescription
goLinkarguments(item, historyData)Return the currently clicked data & historyData
addStararguments(item, collectionData)Return the currently collected data & collectionData
removeStararguments(item, collectionData)Return the currently removed data & collectionData

Examples

Example - Basic Setup

<template>
  <div id="app">
    <side-menu drawer-width="1200px" drawer-top="57px"
               :menu-list="menuList"
               :collection-list="collectionList"
               :history-list="historyList"
               @addStar="changeCallback(arguments)"
               @removeStar="changeCallback(arguments)"
               @goLink="goLink(arguments)">
    </side-menu>
  </div>
</template>
<script>
import SideMenu from "v-side-menu"
export default {
  components: {
    SideMenu
  },
  data() {
    return {
      menuList: [],
      collectionList: [],
      historyList: []
    }
  },
  methods: {
    // Jump to url
    goLink: function (msg) {
      console.log(msg[0]) // item
      console.log(msg[1]) // historyData
    },
    // Processing history and collection data
    changeCallback: function (msg) {
      console.log(msg[0]) // item
      console.log(msg[1]) // collectionData
    }
  }
};
</script>

Example - Customize menu buttons

<template>
  <div id="app">
    <side-menu drawer-width="1200px" drawer-top="57px"
               :drawer-show="open"
               :menu-list="menuList"
               :collection-list="collectionList"
               :history-list="historyList"
               @addStar="changeCallback(arguments)"
               @removeStar="changeCallback(arguments)"
               @goLink="goLink(arguments)">
      <button @click="open = !open">
        <span v-show="!open">点我展开</span>
        <span v-show="open">点我关闭</span>
      </button>
    </side-menu>
  </div>
</template>
<script>
import SideMenu from "v-side-menu"
export default {
  components: {
    SideMenu
  },
  data() {
    return {
      open: false,
      menuList: [],
      collectionList: [],
      historyList: []
    }
  },
  methods: {
    // Jump to url
    goLink: function (msg) {
      console.log(msg[0]) // item
      console.log(msg[1]) // historyData
    },
    // Processing history and collection data
    changeCallback: function (msg) {
      console.log(msg[0]) // item
      console.log(msg[1]) // collectionData
    }
  }
};
</script>

API DATA

// blank: Whether to open a new tab
// token: Whether the URL carries Token
// xxxxx: Define your own attributes
{
    menuList: [
        [
            {
                key: 'cloud_running',
                title: '云运营',
                id: 'cr',
                'sub': [
                    // 概览
                    { id: 'cr_1', key: 'cost_overview', title: '概览', link: '/cloud_overview' }
                ]
            }
        ],
        [
            {
                key: 'operation',
                title: '云运维',
                id: 'op',
                sub: [
                    // 概览
                    { id: 'op_1',  key: 'op_overview', title: '概览', link: '/op_overview', blank: true, token: true },
                    // 配置管理
                    { id: 'op_2',  key: 'op_config_manage', title: '配置管理', link: '/op_config_manage' }
                ]
            },
            {
                key: 'self_manage',
                title: '自服务',
                id: 'sm',
                'sub': [
                    // 概览
                    { id: 'sm_1', key: 'self_overview', title: '概览', link: '/cloud_overview' },
                    // 服务实例
                    { id: 'sm_2', key: 'service_instance', title: '服务实例', link: '/cloud_overview' }
                ]
            }
        ]
    ],
    historyList: [
        { id: 'op_1', key: 'op_overview', title: '概览', link: '/op_overview', blank: true, token: true }
    ],
    collectionList: [
        { id: 'sm_1', key: 'self_overview', title: '概览', link: '/cloud_overview' },
        { id: 'sm_2', key: 'service_instance', title: '服务实例', link: '/cloud_overview' }
    ]
}

License

MIT

1.0.4-beta.6

1 year ago

1.0.4-beta.5

1 year ago

1.0.4-beta.4

2 years ago

1.0.4-beta.3

2 years ago

1.0.4-beta.2

2 years ago

1.0.4-beta.1

2 years ago

1.0.4-beta.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago