我想在QLIK中加载chartJS的Javascript插件。
我已经将定义设置如下。
define( [
'jquery',
'./PropertiesPannel',
'//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.js',
'//cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js',
//'./chartjs-plugin-zoom',
'./chartjs-plugin-annontation',
//'./chartjs-plugin-datalabels',
'qlik'
],
function ( $, ProperitesPannel, Chart,Hammer,ChartAnnotation,qlik) { foo,baa}我认为问题在于,因为包没有按顺序加载,所以插件是在主chartJS插件之前加载的,从而使Chart无法在全球范围内使用。
如何以确保在运行时,所有内容都正确加载的方式加载这些数据?
发布于 2020-06-22 10:55:29
如何以确保在运行时正确加载所有内容的方式加载这些数据?
这个选项称为shim。这里是一个简单的例子:
requirejs.config({
shim: {
'//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.js': ['jquery'],
}
});在本例中,我告诉必需在加载jQuery之前加载Chart.bundle.js,因为它需要它。对于所有不支持AMD的文件,您必须设置它。
您可以在官方页面了解更多信息:https://requirejs.org/docs/api.html#config-shim
https://stackoverflow.com/questions/62427377
复制相似问题