1.全局去掉浏览器默认右键事件
document.oncontextmenu = function(){ return false; }
2.给指定的标签加上右键事件
let info=document.getElementById('SZ')
info.oncontextmenu = function(e){
return false;
}
3.批量给标签加右键事件
/*信息框*/ let info=document.getElementById('SZ') for(let i=0;i<info.childNodes.length;i++){ info.childNodes[i].oncontextmenu =this.showModal this.pageId.infoList.push(info.childNodes[i].id) }
showModal($event) { this.nodes1=$event.path[0].id this.visibles = true },