extjs 4 - 阻止控制器尝试加载视图 js

发布于 2024-12-03 07:28:54 字数 552 浏览 1 评论 0原文

抱歉,如果这是一个真正的菜鸟问题,但在文档中似乎并不明显。

我正在为应用程序创建一个控制器和一个视图。

我的控制器和视图类已经定义。如果我手动实例化视图(例如在 init 方法或其他方法中),那么一切都可以正常工作。

但是,如果我在控制器的视图数组配置中添加视图名称,ext 4 会尝试从服务器再次加载它,即使它已经定义了。

例如

Ext.define('Admin.view.TestView', {

    /* some code */

});

Ext.define('Admin.controller.Test', {
    extend: 'Ext.app.Controller',

    views : [
        'TestView'      // <- this causes ext to try to load the view, even though it's already an existing type
    ]

    /* some code  */

});

我需要做什么来阻止它这样做?

Sorry if that's a real noob question but just doesn't seem obvious in the docs.

I'm creating a controller and a view for an app.

My Controller and View classes are already defined. If i manually instantiate the view (in the init method or whatever for instance) then it all works fine.

But if I add the view name in the views array config of the controller, ext 4 tries to load it again from the server, even though it's already defined.

e.g.

Ext.define('Admin.view.TestView', {

    /* some code */

});

Ext.define('Admin.controller.Test', {
    extend: 'Ext.app.Controller',

    views : [
        'TestView'      // <- this causes ext to try to load the view, even though it's already an existing type
    ]

    /* some code  */

});

What do I need to do to stop it from doing that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角卖回忆 2024-12-10 07:28:55

视图、存储和模型配置将自动创建该类的实例。要阻止这种情况发生,唯一的方法就是不使用它们。使用它的唯一好处是它创建了一个 getter 来访问该实例。我正在尝试改进此功能,但不想破坏此功能。

对于模型来说,这没什么大不了的。对于商店来说,如果您需要一家已经存在的全球商店,那没什么大不了的。

The views, stores, and models configs will automatically create an instance of that class. To stop this from happening, the only way is to not use them. The only benefit to using this is that it creates a getter to access that instance. I am trying to improve this but don't want to break this functionality.

For models it's no big deal. For stores, if you need a global store that is already present it's not that big of a deal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文