我使用requireJS加载取决于xchart.js
的{{1}},并且我继续发出此消息错误d3.js
Uncaught Error: Script error for: d3
并在 require({
paths:{
'd3': 'vendor/charts/d3.min',
'charter': 'vendor/charts/xcharts.min'
}
},['js/vendor/charts/charter.js'],function(App){
App.initial_charter();
});
,我把
js/vendor/charts/charter.js
所以我试过
define(['d3','charter'],function(){
function initial_charter(){
...
}return{
initial_charter: initial_charter
}
}
);
我仍然收到相同的错误消息
更新:我没有更改任何内容,现在在我的控制台中require(['js/vendor/charts/d3.min.js'],function(){
require({
paths:{
'charter': 'vendor/charts/xcharts.min'
}
},['js/vendor/charts/charter.js'],function(App){
App.initial_charter();
});
});
Rmk:我觉得xChart is not defined
真的不稳定,是我还是知道?
答案 0 :(得分:1)
This fiddle将加载d3:
<script>
require = {
paths: {
"d3": "https://rawgithub.com/mbostock/d3/v3.3.4/d3"
},
shim: {
"d3": {
exports: "d3"
}
}
};
</script>
<script src="http://requirejs.org/docs/release/2.1.8/comments/require.js"></script>
<script>
require(["d3"], function (d3) {
console.log.apply(console, arguments);
});
</script>
输出到控制台:
Object {version: "3.3.4", ascending: function, descending: function, min: function, max: function…}