赞
踩
- <el-tree
- ref="treeRef"
- :data="listData"
- :props="defaultProps"
- @node-click="handleNodeClick"
- @node-contextmenu="rightClick"
- />
- <div class="rightMenu" v-show="showRightMenu">
- <ul>
- <li @click="addMenu">
- <el-icon>
- <CirclePlus />
- </el-icon>新建同级
- </li>
- <li @click="addSonMenu">
- <el-icon>
- <CirclePlus />
- </el-icon>新建子级
- </li>
- <li @click="delMenu">
- <el-icon>
- <CircleClose />
- </el-icon>删除功能
- </li>
- </ul>
- </div>
- <script>
-
- const showRightMenu = ref(false)
- const rightClick = (event, data, node, json) => {
- showRightMenu.value = false
- let menu = document.querySelector('.rightMenu')
- menu.style.left = event.clientX + 'px'
- menu.style.top = event.clientY + 'px'
- showRightMenu.value = true
- document.addEventListener('click', show)
- }
- const show = () => {
- showRightMenu.value = false
- }
-
- </script>
-
- <style scoped>
- //样式可以自己定义
- .rightMenu {
- position: fixed;
- z-index: 99999999;
- cursor: pointer;
- border: 1px solid #eee;
- box-shadow: 0 0.5em 1em 2px rgba(0, 0, 0, 0.1);
- border-radius: 6px;
- color: #1a1a1a;
- }
- .rightMenu ul {
- list-style: none;
- margin: 0;
- padding: 0;
- border-radius: 6px;
- }
- .rightMenu ul li {
- padding: 6px 10px;
- background: #fff;
- border-bottom: 1px solid #000;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-around;
- }
- .rightMenu ul li:last-child {
- border: none;
- }
- .rightMenu ul li:hover {
- transition: all 1s;
- background: #92c9f6;
- }
- </style>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。