博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ExtJS中Controller类的动态加载.
阅读量:6983 次
发布时间:2019-06-27

本文共 1407 字,大约阅读时间需要 4 分钟。

hot3.png

参考:

目录结构参考Ext经典目录,此处不在截图。

1,打开Ext的动态加载机制,在app.js首部加入如下代码:

Ext.Loader.setConfig({
enabled: true});
2,确保已经定义Controller类,比如定义一个叫Menu的Controller。方法如下

$touch app/controller/Menu.js && vi app/controller/Menu.js
Menu.js:
Ext.define('Appname.controller.Menu', {    extend: 'Ext.app.Controller',      // leave it as it is    models: ['Event','User'],          // this assumes App.model.* prefix    stores: ['Options','Permissions'], // this assumes App.store.* prefix    views:  ['menu.Bar','SmartButton'],// this assumes App.view.* prefix    requires: [        'App.whatever.other.class',    // auto-load this class as a dependency        'WidgetsLibrary.*',            // auto-load all classes in WidgetsLibrary    ],    init: function(){} // [...]
3. 动态加载。方法如下:

Ext.require(                       'App.controller.Menu',     // this auto-loads all dependencies     function(){         // ... as soon as this class         //    and all its dependencies have loaded...        var controller = Ext.create('App.controller.Menu');  // create an instance        controller.init();                                   // launch init() method    });

如果需要判断,是否已经加载Menu。可使用

if(Ext.ClassManager.isCreated('App.controller.Menu')){    // ... controller has already been loaded and init ... }else{    // we need to auto-load that controller using Ext.require()}
更多内容:

api: 

程序结构: 

转载于:https://my.oschina.net/ethling/blog/131182

你可能感兴趣的文章
(转) 一张图解AlphaGo原理及弱点
查看>>
美联邦调查局 FBI 网站被黑,数千特工信息泄露
查看>>
掉电引起的ORA-1172错误解决过程(二)
查看>>
在网站建设过程中主要在哪几个方面为后期的网站优打好根基?
查看>>
【MOS】RAC 环境中最常见的 5 个数据库和/或实例性能问题 (文档 ID 1602076.1)
查看>>
新年图书整理和相关的产品
查看>>
Struts2的核心文件
查看>>
Spring Boot集成Jasypt安全框架
查看>>
GIS基础软件及操作(十)
查看>>
HDOJ 2041 超级楼梯
查看>>
1108File Space Bitmap Block损坏能修复吗2
查看>>
遭遇DBD::mysql::dr::imp_data_size unexpectedly
查看>>
人人都会设计模式:03-策略模式--Strategy
查看>>
被忽视但很实用的那部分SQL
查看>>
解读阿里云oss-android/ios-sdk 断点续传(多线程)
查看>>
ML之监督学习算法之分类算法一 ——— 决策树算法
查看>>
骡夫电商地址
查看>>
亚信安全火力全开猎捕“坏兔子”,全歼详解
查看>>
智能家居——IoT零基础入门篇
查看>>
《Linux From Scratch》第一部分:介绍 第一章:介绍-1.3. 更新日志
查看>>