简体   繁体   English

与asp.net mvc结合使用时extjs4.2的setPath问题

[英]the setPath issue of extjs4.2 when combining with asp.net mvc

I am new to extJS and met a serious problem described as follows: 我是extJS的新手,遇到了如下严重问题:

I used the Sencha Architect to build my client-side UI. 我使用了Sencha Architect来构建客户端UI。 After finishing it, I copy the generated app folder and app.js to my asp.net mvc project(located in ROOT/Scripts/app and ROOT/Scripts/app.js), and I also copy some dependencies(exr-all.js .etc) from the SDK directory to ROOT/Scripts/extjs.I was using Ext.Loader.setPath() method in my ROOT/Scripts/app.js file to indicate the mapping from specific class name to the specific location, but It does not work. 完成后,我将生成的应用程序文件夹和app.js复制到我的asp.net mvc项目(位于ROOT / Scripts / app和ROOT / Scripts / app.js中),并且还复制一些依赖项(exr-all)。 SDK目录中的js .etc)到ROOT / Scripts / extjs。我在ROOT / Scripts / app.js文件中使用Ext.Loader.setPath()方法来指示从特定类名到特定位置的映射,但是这是行不通的。 In my asp.net mvc project, I have a controller class and the Index action method just return a View(ROOT/Views/RepairList/Index.cshtml) whose code is as follows: 在我的asp.net mvc项目中,我有一个控制器类,而Index操作方法只是返回一个View(ROOT / Views / RepairList / Index.cshtml),其代码如下:

 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>RepairList</title> <script type="text/javascript" src="../../Scripts/extjs/ext-all.js"></script> <link rel="Stylesheet" type="text/css" href="../../Scripts/extjs/resources/css/ext-all.css" /> <link rel="Stylesheet" type="text/css" href="../../Scripts/extjs/resources/css/ext-all.css" /> <script type="text/javascript" src="../../Scripts/extjs/ext-lang-zh_CN.js"></script> <script type="text/javascript" src="../../Scripts/app.js"> </script> </head> <body> </body> </html> 

In my ROOT/Scripts/app.js, the code is as follows: 在我的ROOT / Scripts / app.js中,代码如下:

 Ext.Loader.setConfig({ enabled: true }); Ext.Loader.setPath('repairList', '../../Scripts/app'); Ext.application({ name:'RepairList', requires: [ 'Ext.Loader' ], models: [ 'LineChart', 'RadarChart' ], stores: [ 'MenuStore', 'LineChart', 'RadarChart' ], views: [ 'MainEntry', 'chartPanel' ], controllers: [ 'management', 'forms', 'Info', 'content' ], name: 'repairList', launch: function() { Ext.create('repairList.view.MainEntry'); } }); 

I dont know why the setPath does not work. 我不知道为什么setPath不起作用。 I think it is because the view file is in ROOT/Views/RepairList/Index.cshtml, while the app.js and the app directory is in ROOT/Scripts/app. 我认为这是因为视图文件位于ROOT / Views / RepairList / Index.cshtml中,而app.js和应用程序目录位于ROOT / Scripts / app中。 Moreover, the name of my class generated in the sencha architect is repairlist.model.foo while now they were placed under Scripts folder instead of a directory named repairlist. 而且,在sencha architect中生成的我的类的名称是repairlist.model.foo,而现在它们被放置在Scripts文件夹下,而不是在一个名为repairlist的目录下。 //the file is in the original repairlist/app/view/MainEntry.js file when creating in the sencha architect while now I copy it in the ROOT/Scripts/app/view/MainEntry.js //在sencha架构师中创建文件时,该文件位于原始repairlist / app / view / MainEntry.js文件中,而现在我将其复制到ROOT / Scripts / app / view / MainEntry.js中

 Ext.define('repairList.view.MainEntry', { extend: 'Ext.container.Viewport', alias: 'widget.fillerentry', requires: [ 'repairList.view.headerPanel', 'repairList.view.treeMenu', 'repairList.view.contentPanel', 'Ext.tree.Panel', 'Ext.tab.Panel' ], margin: 0, layout: { type: 'border', padding: 0 }, initComponent: function() { var me = this; Ext.applyIf(me, { items: [ { xtype: 'repairheader', region: 'north' }, { xtype: 'repairtree', region: 'west' }, { xtype: 'repaircontent', region: 'center' } ] }); me.callParent(arguments); } }); 

![enter image description here][1]  ![在此处输入图片描述] [1]

the error message is as follows Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:27845/app/view/MainEntry.js?_dc=1434385119180 ...... ![enter image description here][2] 错误消息如下:无法加载资源:服务器以状态404(未找到)响应http:// localhost:27845 / app / view / MainEntry.js?_dc = 1434385119180 ......![在此处输入图片描述[2]

could anyone tell me why this does not work? 谁能告诉我为什么这行不通? Thanks very much 非常感谢

Two things: 1 - You have set the name config in your application twice. 两件事:1-您已经在应用程序中两次设置了名称config。 2 - When using Ext.application set your paths in the paths config. 2-使用Ext.application时,在路径配置中设置路径。

Ext.application({

    name: 'repairList',
    paths : {
        'repairList' : '../../Scripts/app'
    },

    //...

    launch: function() {
        Ext.create('repairList.view.MainEntry');
    }

});

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

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