你能告诉我为什么会收到这个错误吗?
未捕获TypeError:Ext.Loader.require.setConfig不是函数
我正在尝试将Loader
替换为require
,因此我收到了错误消息。你能告诉我如何解决它吗?
在下面提供我的代码:
var scripts = document.getElementsByTagName('script');
var sportsAllExt4Path = undefined;
for(var idx in scripts){
if(scripts[idx].src !== "" && scripts[idx].src !== undefined){
var path = scripts[idx].src.split('?')[0];
var fileName = path.split('/').slice(-1).join().split('.')[0];
if(fileName === "sportsAll-dev"){
sportsAllExt4Path = path.split('/').slice(0, -1).join('/');
break;
}
}
}
Ext.Loader.require.setConfig({enabled:true});
Ext.Loader.setPath('sportsAll.plugin', sportsAllExt4Path.replace('/scripts/sportsAll-extjs4', '/js/sportsAll/plugin'));
Ext.Loader.setPath('sportsAll', sportsAllExt4Path + '/sportsAll');
Ext.syncRequire([
'sportsAll.Base'
])
答案 0 :(得分:1)
仅使用
Ext.Loader.setConfig({
enabled: true
paths: {
'Ext.ux': '../ux',
...
}
});
是的,只需从代码中删除 require
即可var scripts = document.getElementsByTagName('script');
var sportsAllExt4Path = undefined;
for(var idx in scripts){
if(scripts[idx].src !== "" && scripts[idx].src !== undefined){
var path = scripts[idx].src.split('?')[0];
var fileName = path.split('/').slice(-1).join().split('.')[0];
if(fileName === "sportsAll-dev"){
sportsAllExt4Path = path.split('/').slice(0, -1).join('/');
break;
}
}
}
Ext.Loader.setConfig({enabled:true});
Ext.Loader.setPath('sportsAll.plugin', sportsAllExt4Path.replace('/scripts/sportsAll-extjs4', '/js/sportsAll/plugin'));
Ext.Loader.setPath('sportsAll', sportsAllExt4Path + '/sportsAll');
Ext.syncRequire([
'sportsAll.Base'
])