Skip to content

Commit a455411

Browse files
author
张柯雨
committed
[feature] 优化readme
1 parent 72798c2 commit a455411

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed

README.md

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,81 @@
22

33
> Automatically generate routes and menu by given privilege
44
5+
> 根据用户所给权限自动在自动配置vue-router(hash模式)并展示菜单
6+
57
## Usage
68

9+
#### 安装
10+
11+
``` bash
12+
npm i vue-privilege-menu
13+
```
14+
15+
#### 引入
16+
17+
``` js
18+
import Vue from 'vue'
19+
import VueRouter from 'vue-router'
20+
import privilegeMenu from 'vue-privilege-menu'
21+
22+
Vue.use(VueRouter)
23+
Vue.use(privilegeMenu)
24+
```
25+
26+
#### 示例
27+
28+
``` vue
29+
<template>
30+
<div id="app">
31+
<privilege-menu
32+
:routerMap="routerMap"
33+
:role="role"
34+
router
35+
@select="handleSelect"
36+
@open="handleOpen"
37+
@close="handleClose"/>
38+
<router-view/>
39+
</div>
40+
</template>
41+
42+
<script>
43+
// routerMap详细信息在下面
44+
import { routerMap } from './router'
45+
export default {
46+
name: 'app',
47+
data () {
48+
return {
49+
role: '',
50+
routerMap,
51+
}
52+
},
53+
created() {
54+
this.getRole()
55+
},
56+
methods: {
57+
async getRole(){
58+
let res = await ajax('xxx/xxx')
59+
if(res.success){
60+
this.role = res.data
61+
}
62+
}
63+
handleSelect(key, keyPath) {
64+
console.log('============select==========')
65+
console.log(key, keyPath)
66+
},
67+
handleOpen(key, keyPath) {
68+
console.log('============open==========')
69+
console.log(key, keyPath)
70+
},
71+
handleClose(key, keyPath) {
72+
console.log('============close==========')
73+
console.log(key, keyPath)
74+
},
75+
},
76+
}
77+
</script>
78+
```
79+
780
#### PrivilegeMenu Attribute
881

982
参数 | 说明 | 类型 | 可选值 | 默认值
@@ -22,7 +95,6 @@ menu-trigger|子菜单打开的触发方式(只在 mode 为 horizontal 时有效
2295
router|是否使用 vue-router 的模式,启用该模式会在激活导航时以 index 作为 path 进行路由跳转|boolean|—|false
2396
collapse-transition|是否开启折叠动画|boolean|—|true
2497

25-
2698
#### PrivilegeMenu Events
2799

28100
事件名称|说明|回调参数
@@ -109,9 +181,9 @@ close|sub-menu 收起的回调|index: 收起的 sub-menu 的 index, indexPath:
109181
# install dependencies
110182
npm install
111183

112-
# serve with hot reload at localhost:8080
184+
# 运行example引入本地文件方便修改调试
113185
npm run dev
114186

115187
# build for production with minification
116188
npm run build
117-
```
189+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-privilege-menu",
33
"description": "Automatically generate routes and menu by given privilege",
4-
"version": "1.1.1",
4+
"version": "1.1.3",
55
"author": "zhangkeyu",
66
"license": "MIT",
77
"private": false,

0 commit comments

Comments
 (0)