日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

element ui tree结构双击单机右键事件

發布時間:2023/12/20 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 element ui tree结构双击单机右键事件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<el-tree:data="data":props="defaultProps"@node-click="handleNodeClick"@node-contextmenu="rightClick"default-expand-all></el-tree><!-- 右鍵菜單 --><div id="menuyuan" class="menuDiv"><ul class="menuUl"><liv-for="(item, index) in menus":key="index"@click.stop="infoClick(index)"><i :class="item.icon"></i> {{ item.name }}</li></ul></div>

1、以上是html? 包括右鍵菜單

2、data中

//雙擊nodeCount: 0,preNodeId: null,curNodeId: null,nodeTimer: null,//右鍵currentData: "",currentNode: "",menuVisible: false,firstLevel: false,Node: {},menus: [{ name: "菜單一", operType: 1, icon: "el-icon-tickets" },{ name: "二", operType: 2, icon: "el-icon-folder-opened" },{ name: "三", operType: 3, icon: "el-icon-folder-add" },{ name: "四", operType: 4, icon: "el-icon-refresh-right" },{ name: "五", operType: 5, icon: "el-icon-close" },],

3、methods中

//雙擊handleNodeClick(data, node, prop) {//這里可以調用單擊事件//這是單擊隱藏右鍵菜單let menu = document.querySelector("#menuyuan");menu.style.display = "none";// console.log(data, node, prop);this.nodeCount++;if (this.preNodeId && this.nodeCount >= 2) {this.curNodeId = data.$treeNodeId;this.nodeCount = 0;if (this.curNodeId == this.preNodeId) {this.compile(node);this.curNodeId = null;this.preNodeId = null;return;}}this.preNodeId = data.$treeNodeId;this.nodeTimer = setTimeout(() => {this.preNodeId = null;this.nodeCount = 0;}, 300);},// 右擊的功能 rightClick(event, object, Node, element) {this.Node = Nodethis.currentData = object;this.currentNode = Node;if (Node.level === 1) {this.firstLevel = true;} else {this.firstLevel = false;}this.menuVisible = true;let menu = document.querySelector('#menuyuan')// /* 菜單定位基于鼠標點擊位置 */menu.style.left = event.clientX + 20 + "px";menu.style.top = event.clientY - 25 + "px";menu.style.display = "block";},// 右擊自定義菜單的點擊事件infoClick(index) {if (index === 0) {// 屬性console.log("屬性");}else if(index === 1){}else if(index === 2){}else if(index === 3){}else if(index === 4){}let menu = document.querySelector("#menuyuan");menu.style.display = "none";},

4、給右鍵菜單加個樣式

.menuDiv {display: none;position: absolute;.menuUl {height: auto;width: auto;font-size: 14px;text-align: left;border-radius: 4px;border: none;background-color: #ffffff;color: #606266;list-style: none;border: 1px solid #ebeef5;li {width: 140px;height: 35px;line-height: 35px;padding: 0 10px;cursor: pointer;border-bottom: 1px solid rgba(255, 255, 255, 0.47);&:hover {display: block;background-color: #ecf5ff;color: #7abbff;}}}}

個人使用的一些總結,使用中發現問題隨時反饋

總結

以上是生活随笔為你收集整理的element ui tree结构双击单机右键事件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。