Highcharts自定义事件插件右键单击事件未触发

时间:2019-03-22 15:13:58

标签: javascript events highcharts contextmenu

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(并单击鼠标左键),则该事件将正常进行。

问题的可能原因是什么?

1 个答案:

答案 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的情况下绕过此操作的知识