项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

пре 4 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # vue-context-menu
  2. > Vue 2.0 右键菜单组件,菜单内容可以随意自定义
  3. ![Preview](https://github.com/binggg/vue-context-menu/blob/master/demo/assets/demo.jpeg?raw=true)
  4. ## 安装
  5. ```
  6. npm install @xunlei/vue-context-menu
  7. ```
  8. ## 在线Demo
  9. https://xunleif2e.github.io/vue-context-menu/demo/dist
  10. ## 使用
  11. ### 1. 注册组件
  12. #### 方式1 利用插件方式全局注册
  13. ```javascript
  14. import VueContextMenu from '@xunlei/vue-context-menu'
  15. import Vue from 'vue'
  16. Vue.use(VueContextMenu)
  17. ```
  18. #### 方式2 局部注册
  19. ```javascript
  20. import { component as VueContextMenu } from '@xunlei/vue-context-menu'
  21. export default {
  22. // ...
  23. components: {
  24. 'vue-context-menu': VueContextMenu
  25. }
  26. }
  27. ```
  28. #### 方式3 独立版本引入,自动全局注册
  29. > 前提是 vue 也是独立版本通过script标签引入
  30. ```html
  31. <script src="./node_modules/dist/vue-context-menu.js"></script>
  32. ```
  33. ### 2. 模版语法
  34. ```html
  35. <context-menu class="right-menu"
  36. :target="contextMenuTarget"
  37. :show="contextMenuVisible"
  38. @update:show="(show) => contextMenuVisible = show">
  39. <a href="javascript:;" @click="copyMsg">复制</a>
  40. <a href="javascript:;" @click="quoteMsg">引用</a>
  41. <a href="javascript:;" @click="deleteMsg">删除</a>
  42. </context-menu>
  43. ```
  44. ## Props
  45. | 参数 | 说明 | 类型 | 可选值 | 默认值 |
  46. |-------------------------|-------|------|--------|--------|
  47. | target | 触发右键事件的元素 | Element | - | - |
  48. | show | 是否显示右键菜单 | Boolean | - | false |
  49. ## Events
  50. | 事件名 | 说明 | 事件参数
  51. |-------------------------|-------|------|
  52. | update:show | 右键菜单显示/隐藏时触发 | 是否显示 |
  53. ## 注意
  54. 如果target是某个兄弟元素,可以使用 `$refs`来访问,但是注意请在父组件mounted 之后获取。
  55. 参考 https://cn.vuejs.org/v2/guide/components.html#子组件索引
  56. ## ChangeLog
  57. - [1.0.1] 2017-07-10
  58. - 修复 target 为空时可能出错的bug
  59. - [1.0.0] 2017-06-23
  60. - 实现右键菜单基本功能
  61. ## Development Setup
  62. ``` bash
  63. # install deps
  64. npm install
  65. # serve demo at localhost:8080
  66. npm run dev
  67. # build library and demo
  68. npm run build
  69. # build library
  70. npm run build:library
  71. # build demo
  72. npm run build:demo
  73. ```
  74. ## License
  75. [MIT](http://opensource.org/licenses/MIT)
  76. Copyright (c) 2017 赵兵