我想在require config中创建一个不存在的模块,但只是加载依赖项。例如:
window["requirejs"].config({
paths: {
main : "/Scripts/" + "/main",
jquery : "/Scripts/" + "/jquery-2.1.3.min",
HiChartsWithExtensions : false,//what to put here???
HighCharts : "/Scripts/" + "/HighCharts/highcharts",
HighChartsExporting : "/Scripts/" + "/HighCharts/modules/exporting",
HighChartsExportingCsv : "/Scripts/" + "/HighCharts/modules/export-csv",
}
, shim : {
main : {
deps : ["HiChartsWithExtensions"]
},
HiChartsWithExtensions : {
deps : ["HighChartsExporting"]
},
HighCharts: {
deps : ["jquery"],
exports: '$'
},
"HighChartsExporting" : {
deps : ["HighCharts"]
},
"HighChartsExportingCsv" : {
deps : ["HighChartsExporting"]
}
}
});
window["require"](['main']);
main取决于HiChartsWithExtensions但requirejs尝试为其加载js文件。我希望HiChartsWithExtensions能够在没有该模块实际返回任何内容的情况下加载依赖项。
答案 0 :(得分:1)
现在;以下解决方案有所帮助:
window["requirejs"].config({
paths: {
main : "/Scripts/" + "/main",
jquery : "/Scripts/" + "/jquery-2.1.3.min",
HiChartsWithExtensions : "/Scripts/" + "/HighCharts/modules/export-csv",
//deepest dependency here (csv depends on exporting depends on highcharts)
HighCharts : "/Scripts/" + "/HighCharts/highcharts",
HighChartsExporting : "/Scripts/" + "/HighCharts/modules/exporting",
HighChartsData : "/Scripts/" + "/HighCharts/modules/data",
HighChartsDrilldown : "/Scripts/" + "/HighCharts/modules/drilldown"
}
, shim : {
main : {
deps : ["HiChartsWithExtensions"]
},
HiChartsWithExtensions : {
deps : ["HighChartsExporting","HighChartsData","HighChartsDrilldown"]
},
HighCharts: {
deps : ["jquery"],
exports: '$'
},
"HighChartsExporting" : {
deps : ["HighCharts"]
},
"HighChartsData" : {
deps : ["HighCharts"]
},
"HighChartsDrilldown" : {
deps : ["HighCharts"]
}
}
});
window["require"](['main']);