【问题标题】:Sencha Cmd unable to parse custom code in app.jsSencha Cmd 无法解析 app.js 中的自定义代码
【发布时间】:2014-05-21 08:47:09
【问题描述】:

由于某种原因,Sencha Cmd 在使用自定义代码解析 app.js 时失败。下面是我正在部署到测试(未缩小的 JavaScript,但在单个文件中)或生产(缩小的 JavaScript)的应用程序的 sn-p。

浏览器从已部署的文件夹(带有 all-classes.js)中抛出以下 JavaScript 异常:

(注意:所有js源代码的文件夹运行良好)

GET http://localhost/App/App/model/app/CheckTreeNode.js?_dc=1396967410158 404 (Not Found) all-classes.js:10841
GET http://localhost/App/App/store/app/UserPreferenceNodes.js?_dc=1396967410159 404 (Not Found) all-classes.js:10841
GET http://localhost/App/app/controller/ViewportAdmin.js?_dc=1396967410177 404 (Not Found) all-classes.js:10841

...

Uncaught Error: [Ext.Loader] Failed loading 'App/model/app/CheckTreeNode.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'App/store/app/UserPreferenceNodes.js', please verify that the file exists all-classes.js:11259
Uncaught Error: [Ext.Loader] Failed loading 'app/controller/ViewportAdmin.js', please verify that the file exists 

我尝试通过在我的 Ext.application 类中添加“需要”配置来解决问题,但这并没有帮助。如何强制 Sencha Cmd 看到这些文件? Sencha Touch 有一个解决方案,允许您将文件添加到“app.json”。也许我不知道的 ExtJS 应用程序有类似的解决方案?

如果有更优雅的解决方案,我愿意接受。我需要我的一堆类的构造函数中的用户首选项,所以这是我可以加载它并在调用它们时准备好的唯一地方。如果在 MVC 中构建类时有不同的方式来加载可用的数据,那么我可以使用不同的解决方案。至于有两个视口,这是我发现的工作,所以这就是 ViewportAdmin 是什么。只是第二个视口。

app.js 源代码:

Ext.应用程序({ 名称:'应用程序',

extend: 'App.Application',
requires: [
    'App.store.app.UserPreferences',
    'App.view.ViewportAdmin'
],
autoCreateViewport: false,
launch: function () {        

    Ext.StoreManager.lookup('App.store.app.UserPreferences').on('load', function () {

        if (window.location.href.indexOf('/App/index.aspx?admin=true') > -1) {
            Ext.create('App.view.ViewportAdmin');
        }
        else if (window.location.href.indexOf('/App/index.aspx') > -1) {
            Ext.create('App.view.Viewport');
        }
    });


}

});

【问题讨论】:

    标签: javascript extjs extjs4 sencha-cmd


    【解决方案1】:

    问题不是由于我所怀疑的。将应用程序部署到测试后(运行命令“sencha app build testing”,我在下面的两行代码上放置了一个断点。事实证明,它出错的控制器有没有被使用的商店。它失败了,因为那个。CheckTreeNodes.js 是该商店中使用的模型。我只是将其从商店列表中删除以解决它。

    all-classes.js 中的代码(我认为是从 YUI 压缩器生成的):

    script.src = url;
    (Loader.documentHead || document.getElementsByTagName('head')[0]).appendChild(script);
    

    我查看了 Google Chrome 中的调用堆栈,发现匿名函数调用(在调用堆栈中)正在显示来自 ViewportAdmin 控制器的商店列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多