初次使用extjs4的版本,在配置学习Ext.Loader()进行js文件的动态加载机制,由于各种原因导致多次失败,纠结2天,现将解决时出现的问题及需要注意事项进行记录

开发环境myeclipse8.5,tomcat6.
目录结构:
WebRoot
-->02(文件夹)
   -->createWindow.js
   -->createWindow.html
   -->ux(文件夹)
      -->window.js

createWindow.html中,引入ext环境文件(ext-all.css,bootstrap.js),引入createWindow.js文件
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <title>extjs--创建window</title>
            <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
            <meta http-equiv="description" content="this is my page">
            <meta http-equiv="content-type" content="text/html; charset=UTF-8">
            <link rel="stylesheet" type="text/css" href="../extjs-4.1.1/resources/css/ext-all.css">
            <script type="text/javascript" src="../extjs-4.1.1/bootstrap.js"></script>
            <script type="text/javascript" src="createWindow.js"></script>
        </head>
        <body>
        </body>
    </html>

createWindow.js
    (function(){
        Ext.Loader.setConfig({
            enabled:true,
            paths:{
                //定义一个命名空间,路径处添加相对路径
                myApp:'ux'
            }
        });
        Ext.onReady(function(){
            Ext.create('ux.window',{
                //可以根据个性修改值
                title:'个性定制的title',
                requires:['ux.window']
            }).show();
        });
    })();

window.js
Ext.define('ux.window',{
    extend:'Ext.window.Window',
    width:200,
    height:90,
    title:'me is myExt.Window',
    initComponent:function(){
        this.callParent(arguments);
    }
});

在createWindow.js中定义的命名空间是以当前文件位置而填写的相对路径(相对路径不能向上级回退[../])
在window.js中define的第一个参数实际就是相对于 = (命名空间路径 + 文件名)组成
例如以上目录改为如下

-->02(文件夹)
   -->createWindow.js
   -->createWindow.html
   -->ux(文件夹)
      -->window(文件夹)
         -->window.js
则createWindow.js中paths改为{myApp:'ux/window'}
  window.js中define中第一个参数改为'ux.window.window'
  createWindow.js中Ext.create()第一个参数改为'ux.window.window'
            requires改为'ux.window.window'

Extjs4 -- Ext.loader命名空间的配置的更多相关文章

  1. ExtJS笔记 Ext.Loader

    Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most co ...

  2. Ext.Loader

    Ext.Loader是Ext JS4动态加载的核心,等价于Ext.require简写. Ext.Loader支持异步和同步加载的方法. 异步 优点: 1.跨域 2.不需要web服务器 3.调试方便(可 ...

  3. Ext4报错Uncaught Ext.Loader is not enabled

    提示: Uncaught Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing requ ...

  4. sencha警告:[WARN][Anonymous] [Ext.Loader] Synchronously loading 'Ext.field.Text'

    chrome开发者工具下提示: [WARN][Anonymous] [Ext.Loader] Synchronously loading 'Ext.field.Text'; consider addi ...

  5. Spring配置文件中未引入dubbo命名空间头部配置而引起的错误案例

    问题描述: Spring配置文件中未引入dubbo命名空间的头部配置而引起项目启动时报出如下错误信息: org.springframework.beans.factory.xml.XmlBeanDef ...

  6. Webpack的详细配置,[Webpack中各种loader的安装配置]

    在使用webpack的时候,你是不是被以下这种报错所困扰: 注意看 黄色框中标注的 You may need an appropriate loader to handle this file typ ...

  7. create react app的 css loader 进行局部配置

    { test: cssRegex, exclude: cssModuleRegex, use: getStyleLoaders({ importLoaders: 1, sourceMap: isEnv ...

  8. Extjs-4.2.1(二)——使用Ext.define自定义类

    鸣谢:http://www.cnblogs.com/youring2/archive/2013/08/22/3274135.html --------------------------------- ...

  9. EXTJS4自学手册——EXT基本方法、属性(mixins多继承、statics、require)

    1.mixins 说明:类似于面向对象中的多继承 <script type="text/javascript"> Ext.onReady(function () {// ...

随机推荐

  1. linux 内核升级

    LINUX 内核升级 linux 内核官网 https://www.kernel.org/ POST BIOS(boot sequence) 所选择的启动设备次序的MBR中是否有引导程序, ----& ...

  2. Android高级控件--AdapterView与Adapter

    在J2EE中提供过一种非常好的框架--MVC框架,实现原理:数据模型M(Model)存放数据,利用控制器C(Controller)将数据显示在视图V(View)上.在Android中有这样一种高级控件 ...

  3. 概率dp专场

    专题链接 第一题--poj3744 Scout YYF I  链接 (简单题) 算是递推题 如果直接推的话 会TLE 会发现 在两个长距离陷阱中间 很长一部分都是重复的 我用 a表示到达i-2步的概率 ...

  4. volatile关键字并不能作为线程计数器

    在java线程并发处理中,有一个关键字volatile的使用目前存在很大的混淆,以为使用这个关键字,在进行多线程并发处理的时候就可以万事大吉. Java语言是支持多线程的,为了解决线程并发的问题,在语 ...

  5. 解决hibernate删除时的异常

    由于关联关系是一对多和多对一的关系,于是在代码中需要删除多的一方的对象时出现了 deleted object would be re-saved by cascade (remove deleted ...

  6. vCSA加域&vcenter关联域&设置管理员权限

    vCSA 与 Windows vCenter对比 1.部署起来更简单快捷. 2.vCSA基于Linux授权费用节省. 3.功能在6.0之后达到与Windows vCenter一样的功能,之后可能会反超 ...

  7. web.xml中的contextConfigLocation在spring中的作用

    在web.xml中通过contextConfigLocation配置spring, contextConfigLocation参数定义了要装入的 Spring 配置文件.默认会去/WEB-INF/下加 ...

  8. js 判断是什么类型浏览器

    //  firefoxif ( window.sidebar && "object" == typeof( window.sidebar ) && ...

  9. C# 技巧(3) C# 操作 JSON

    RestAPI中, 经常需要操作json字符串,  需要把json字符串"反序列化"成一个对象, 也需要把一个对象"序列化"成一字符串. C# 操作json, ...

  10. 安装phpredisadmin linux nginx服务器下

    1.下载phpRedisAdmin:git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git 2.cd phpRedisAdmin   ...