如何解决ExtJS的“同步加载"问题警告 [英] How to tackle ExtJS "Synchronously loading" warning

查看:24
本文介绍了如何解决ExtJS的“同步加载"问题警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 ExtJS 4+ 与 异步加载一起使用时 人们应该熟悉这种警告:

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

如何确定是哪个 JavaScript 模块(控制器、组件等)导致了此警告?IE.需要列表.

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.

推荐答案

在 chrome 中,在您的堆栈跟踪中,(我认为 Firefox 现在也进行堆栈跟踪?)在模块中调用的文件通常(总是?)第一个不是 ext-all 的文件.

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 是用来自动化东西的东西(例如 js-minification),所以你不能真正自动化它本身.

Ext.require is something used TO automate stuff ( eg js-minification) so you can't really automate it in and of itself.

当您声明一个组件(使用 Ext.defineExt.create )时,您应该指定 Ext 将用于该组件的组件的模块Ext.require(好吧,如果你至少想摆脱这个警告)

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

参见 mitchsimeons 答案:http://www.sencha.com/forum/showthread.php?178888-Tons-of-Synchronously-Loading-Warning-Messages

See mitchsimeons answer: 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

and a blog post on why requires: http://www.sencha.com/blog/using-ext-loader-for-your-application

这篇关于如何解决ExtJS的“同步加载"问题警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆