<el-tree :highlight-current="highlight" :data="folderList" :props="defaultProps" @node-contextmenu="rightClick" @node-click="handleNodeClick"  style="min-width: 100%;display: inline-block;"></el-tree>
 
<div id="contextmenu"
           v-show="menuVisible"
           class="menu">
        <div class="contextmenu__item" @click="addDialogFolder"
             >添加</div>
        <div class="contextmenu__item"
             >删除</div>
         <div class="contextmenu__item"
         >更名文件</div>
    </div>
methods: {
          foo() {
            // 取消鼠标监听事件 菜单栏
            this.menuVisible = false
            document.removeEventListener('click', this.foo) // 关掉监听,
          },
          styleMenu(menu) {
            if (event.clientX > 1800) {
              menu.style.left = event.clientX - 100 + 'px'
            } else {
              menu.style.left = event.clientX + 1 + 'px'
            }
            document.addEventListener('click', this.foo) // 给整个document新增监听鼠标事件,点击任何位置执行foo方法
            if (event.clientY > 700) {
              menu.style.top = event.clientY - 30 + 'px'
            } else {
              menu.style.top = event.clientY - 10 + 'px'
            }
          },
          rightClick(row, column, event){
            // if(column.id){
              this.pid = column.id;
              this.testModeCode = row.testModeCode
              this.menuVisible = false // 先把模态框关死,目的是 第二次或者第n次右键鼠标的时候 它默认的是true
              this.menuVisible = true // 显示模态窗口,跳出自定义菜单栏
              // event.preventDefault() //关闭浏览器右键默认事件
              this.CurrentRow = row
              var menu = document.querySelector('.menu')
              this.styleMenu(menu)
            // }else{
            // }
            
          },
}
 
style{
.contextmenu__item {
  display: block;
  line-height: 34px;
  text-align: center;
}
.contextmenu__item:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.menu {
  position: absolute;
  background-color: #fff;
  width: 100px;
  /*height: 106px;*/
  font-size: 12px;
  color: #444040;
  border-radius: 4px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  white-space: nowrap;
  z-index: 1000;
}
.contextmenu__item:hover {
  cursor: pointer;
  background: #66b1ff;
  border-color: #66b1ff;
  color: #fff;
}

}

最新文章

  1. MyBank(自助银行)系统
  2. Gunicorn 文档翻译
  3. python——常用功能之文本处理
  4. java 获取请求客户端的真实IP地址
  5. maven手动安装jar到本地仓库
  6. NSThead
  7. 2 WPF之XMAL----XMAL概览
  8. Service的一些使用
  9. Matrix(线段树版)
  10. 保障MySQL安全的14个最佳方法
  11. linux loadavg详解(top cpu load)
  12. knockout笔记
  13. MyBatis java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
  14. Alamofire源码解读系列(四)之参数编码(ParameterEncoding)
  15. centos7系统配置记录SFTP操作日志
  16. Spring Boot 构建电商基础秒杀项目 (九) 商品列表 &amp; 详情
  17. linux 终端命令行的快捷键列表
  18. Linux 文件特殊权限_013
  19. 10个有趣的Python教程,附视频讲解+练手项目。
  20. Activity与view

热门文章

  1. Docker 基础 - 2
  2. JS原生上传文件,读取文件格式,控制文件只可以上传某些格式,并使用fileReader转换格式
  3. 在Spring Boot中整合Katharsis,来快速开发JSON API的Web应用
  4. 2023年 .NET Monorepo 来了
  5. java的部分特性与下载安装
  6. MySQL-字段约束条件
  7. Thymeleaf的内置对象、SpringBoot整合Thymeleaf和JDBC
  8. 机器学习-集成学习LightGBM
  9. clicknium-划时代的自动化
  10. JZOJ 3528. 【NOIP2013模拟11.7A组】图书馆(library)