http://jsfiddle.net/ovbpacrt/1/
在上面的右键单击上无法触发contextmenu
事件。
chart = new Highcharts.Chart(
{
series:[
{
"data": data,
type: 'pie',
animation: false,
point:{
events:{
contextmenu: function (event) {
alert(this.id);
}
}
}
}
],
"chart":{
"renderTo":"container"
},
});
如果我将contextmenu
更改为click
(并单击鼠标左键),则该事件将正常进行。
问题的可能原因是什么?
答案 0 :(得分:1)
您不能使用原始github文件,因为它们会被CORS阻止。
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/blacklabel/custom_events/master/js/customEvents.js with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
尝试使用CDN https://cdn.jsdelivr.net/npm/highcharts-custom-events@2.2.4/js/customEvents.min.js
在这里您可以学到更多关于如何在没有CDN https://gist.github.com/jesperorb/6ca596217c8dfba237744966c2b5ab1e的情况下绕过此操作的知识