我想使用requirejs使用canvasjs。像这样的代码:
require.config({
shim: {
'canvasjs' : {
deps: ['jquery'],
chart: {
exports: 'Chart'
}
}
},
paths: {
"jquery": "../js/jquery-1.10.2.min",
"canvasjs": "../js/canvasjs.min"
}
});
require(["jquery", "canvasjs"], function($, CanvasJS) {
function AppViewModel() {
var self = this;
}
var chart = new CanvasJS.Chart("chartContainer", {})
}
)
代码有什么问题?感谢
答案 0 :(得分:2)
看起来像名称冲突,从Require调用的回调参数中删除CanvasJS。
尝试关注
require.config({
shim: {
'canvasjs' : {
deps: ['jquery'],
chart: {
exports: 'Chart'
}
}
},
paths: {
"jquery": "../js/jquery-1.10.2.min",
"canvasjs": "../js/canvasjs.min"
}
});
require(["jquery", "canvasjs"], function($) {
function AppViewModel() {
var self = this;
}
var chart = new CanvasJS.Chart("chartContainer", {})
}
)