如何解决ExtJS“同步加载”警告 [英] How to tackle ExtJS "Synchronously loading" warning
问题描述
当使用ExtJS 4+与异步加载一个人会熟悉这种警告:
[Ext.Loader]同步加载'MY.particular.module ;
考虑添加Ext.require('MY.particular.module')Ext.onReady
如何识别哪个JavaScript模块(控制器,组件等)是否导致此警告?即在 需要
列表。
什么是 right 围绕纠正这些警告?自动化的方式是否存在?
现在唯一的办法就是设置一个调试点,在这里提醒警告,并追溯到哪个文件导致正在生成的警告。
Ext.require
是用于自动化东西(例如js-minification)的东西,所以你它本身并不能真正自动化。
当您声明一个组件(使用 Ext.define
或 Ext.create
)你应该使用
Ext.require
指定Ext组件使用的组件(如果你想摆脱此警告至少)
您正在使用的每个自定义组件应该或多或少遵循相同的想法:
Ext.define('My.app.Panel',{
extends:'Ext.panel.Panel',//
requires :$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ b config){
this.callParent(arguments);
// ...
},
statics:{
method:function(){
return'abc';
}
}
});
如果你不关心性能,只想摆脱杂散警告(疯狂技术上,你可以在加载器配置中填写你的错误信息。
Ext.loader.setConfig({
启用:true,
路径:{
'我的':'my_own_path'
},
onError:function(){} //或自定义处理程序?:D
请参阅mitchsimeons答案: http://www.sencha.com/forum/showthread.php?178888-Tons-of-Synchronously-Loading-Warning-Messages
以及为什么需要的博文:
http://www.sencha.com/blog/using-ext-loader-for-your-application
When using ExtJS 4+ with asynchronous loading one would be familiar with this sort of warning:
[Ext.Loader] Synchronously loading 'MY.particular.module';
consider adding Ext.require('MY.particular.module') above Ext.onReady
How to identify which JavaScript module (be it a controller, a component, etc) is causing this warning? I.e. the place where include module being synchronously loaded in the requires
list.
What is the right way to go around correcting these warnings? Does an automated way to do this exist?
P.S. The only way to do this right now, is to set a debug point where the warning is raised, and trace back to which line in which file is leading to the warning being generated.
In chrome, in your stacktrace, (I think Firefox does stacktraces as well nowadays?) the file that is calling in a module is usually (always?) the 1st file that is not ext-all.
Ext.require
is something used TO automate stuff ( eg js-minification) so you can't really automate it in and of itself.
When you declare a component ( using Ext.define
or Ext.create
) you should be specifying the modules the component that Ext is going to use for the component with Ext.require
( well, if you want to get rid of this warning atleast )
Every custom component that you are using should more or less follow the same idea:
Ext.define('My.app.Panel', {
extend: 'Ext.panel.Panel', //
requires: [
'My.app.PanelPart2', //Hey! warning is gone!
'My.app.PanelPart3'
]
constructor: function (config) {
this.callParent(arguments);
//...
},
statics: {
method: function () {
return 'abc';
}
}
});
And if you don't care about performance, and only want to get rid of stray warnings ( insanity technically, you can just muck your error message, in the loader config .
Ext.loader.setConfig({
enabled: true,
paths: {
'My': 'my_own_path'
},
onError:function(){}//or custom handler? :D
See mitchsimeons answer: http://www.sencha.com/forum/showthread.php?178888-Tons-of-Synchronously-Loading-Warning-Messages
and a blog post on why requires: http://www.sencha.com/blog/using-ext-loader-for-your-application
这篇关于如何解决ExtJS“同步加载”警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!