繁体   English   中英

Sencha Cmd无法解析app.js中的自定义代码

[英]Sencha Cmd unable to parse custom code in app.js

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

浏览器从已部署的文件夹(带有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类中添加“ requires”配置来修复问题,但这没有帮助。 如何强制Sencha Cmd看到这些文件? Sencha Touch有一个解决方案,它允许您将文件添加到“ app.json”。 也许我不知道针对ExtJS应用程序的类似解决方案?

如果有更优雅的解决方案,我欢迎他们。 我需要一堆类的构造函数中的用户首选项,因此这是我可以加载它并准备好在调用它们时准备的唯一位置。 如果在MVC中构建类时有其他方法可以加载数据,则可以使用其他解决方案。 至于有两个视口,这就是我发现可以使用的功能,所以这就是ViewportAdmin。 只是第二个视口。

app.js源代码:

Ext.application({name:'App',

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');
        }
    });


}

});

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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM