在 ExtJS 4 MVC 中将多个视图附加到控制器

发布于 2024-11-09 08:20:09 字数 1638 浏览 3 评论 0原文

这是使用标准 ExtJS 4 MVC 库和结构。

我正在尝试将多个视图附加到单个控制器,以便稍后创建它们的实例以添加到面板中。不幸的是,当我添加第二个视图时,我收到了有关视图的错误,并且 ExtJS 阻止了它出现的语法错误,因此我无法看到问题出在哪里。

如果我从下面的列表中注释掉 ViewOrders ,它工作正常,但如果它在那里,那么我会收到以下错误:

An uncaught error was raised with the following data: ext-all-debug-with-comments.js (line 7864)
msg:
"The following classes are not declared even if their files have been loaded:   'PVAL_App.view.ViewOrders'. Please check the source code of their corresponding files for possible typos: 'app/view/ViewOrders.js'"

sourceClass: "Ext.Loader"
sourceMethod: "onFileLoaded"

这是我的控制器:

Ext.define('PVAL_App.controller.Viewport', {
    extend: 'Ext.app.Controller',

    views: [
      'Viewport', 'ViewOrders'
    ],

    init: function() {
      console.log('Viewport controller init()');
    }
});

这是我的 ViewOrders 视图:

Ext.define('PVAL_APP.view.ViewOrder', {

    /* Begin Definitions */
    extend: 'Ext.panel.Panel',
    alias: 'widget.ViewOrders',

    requires: [
        'Ext.panel.Panel',
        'Ext.data.ArrayStore'
    ],

    border:false,
    layout: 'fit',
    //autoScroll: true,

    initComponent: function() {
    }
});

我怀疑这是需要的,但这是我的应用程序文件:

Ext.Loader.setConfig(
{
  enabled: true
});
Ext.application({
  name: 'PVAL_App',

  appFolder: 'app',

  autoCreateViewport: true,

  controllers: [
    'PVAL_App', 'Viewport'
  ],

  launch:function() {
    // Nothing yet.
    //console.log(this.controllers);
  }
});

I似乎无法弄清楚这是否是语法错误或者这是否是框架的问题。如果我尝试从一个控制器中链接到另一个控制器,我也遇到过类似的问题,这让我相信这可能是框架的限制。

This is using the standard ExtJS 4 MVC library and structure.

I am trying to attach multiple views to a single controller so I can create instances of them later to add to panels. Unfortunately I am getting errors about the view when I add the second one and ExtJS is blocking the syntax errors it appears so that I am unable to see where the issue is.

If I comment out ViewOrders from the list below it works fine, but if it is in there then I get the following error:

An uncaught error was raised with the following data: ext-all-debug-with-comments.js (line 7864)
msg:
"The following classes are not declared even if their files have been loaded:   'PVAL_App.view.ViewOrders'. Please check the source code of their corresponding files for possible typos: 'app/view/ViewOrders.js'"

sourceClass: "Ext.Loader"
sourceMethod: "onFileLoaded"

Here is my controller:

Ext.define('PVAL_App.controller.Viewport', {
    extend: 'Ext.app.Controller',

    views: [
      'Viewport', 'ViewOrders'
    ],

    init: function() {
      console.log('Viewport controller init()');
    }
});

Here is my ViewOrders view:

Ext.define('PVAL_APP.view.ViewOrder', {

    /* Begin Definitions */
    extend: 'Ext.panel.Panel',
    alias: 'widget.ViewOrders',

    requires: [
        'Ext.panel.Panel',
        'Ext.data.ArrayStore'
    ],

    border:false,
    layout: 'fit',
    //autoScroll: true,

    initComponent: function() {
    }
});

I doubt this is needed but this is my application file:

Ext.Loader.setConfig(
{
  enabled: true
});
Ext.application({
  name: 'PVAL_App',

  appFolder: 'app',

  autoCreateViewport: true,

  controllers: [
    'PVAL_App', 'Viewport'
  ],

  launch:function() {
    // Nothing yet.
    //console.log(this.controllers);
  }
});

I cannot seem to figure out if it is a syntax error or if this is an issue with the framework. I have experienced close to the same issue if I try to link to another controller from within one which makes me believe that this might be a constraint of the framework.

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

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

发布评论

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

评论(1

故事未完 2024-11-16 08:20:09

这里的问题是 app/view/ViewOrders.js 脚本中的类名与视图名称不匹配。您需要的是复数形式(且大小写正确),而不是 Ext.define('PVAL_APP.view.ViewOrder', {) Ext.define('PVAL_App.view.ViewOrders', { >. 或者您可以更改文件名并引用单数并更正大小写。

The problem here is that the class name in your app/view/ViewOrders.js script does not match the view name. Instead of Ext.define('PVAL_APP.view.ViewOrder', { you need the plural (and correct case) Ext.define('PVAL_App.view.ViewOrders', {. Either that our you can change your filename and refernece to the singular and just correct the case.

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