一个Ext.app.Application代表一个整体的应用,需要为它绑定一些组件,如Views,Models,Controllers
Ext.application({
name:'Blog',//a blog application
models:['Posts','Comments'],
controllers:['Posts','Comments'],
launch:function(){}
});
Views一般不直接绑定在Application上,因为它是被Controllers管理的,所以一般创建Controllers的时候绑定Views。
Ext.define('MyApp.controller.Posts',{
extend:'Ext.app.Controller',
views:['posts.List','posts.Edit'],
//the rest of controller here
});
常用配置选项:
appFolder:String
the path to the directory which contains all application’s classes.
包含应用所有class文件的目录路径。默认为“app”。
autoCreateViewport:Boolean
true to automatically load and instantiate AppName.view.Viewport before firing the launch function.
在launch定义的函数执行之前,真正的自动加载和实例化AppName.view.Viewport。默认为false
defaultUrl:String
when the app is first loaded,the Url will be redirected to.
应用第一次加载时,该URL将会被重定向。
id:String
the id of this controller,you can use this id when dispatching.
controller的Id,请求转发的时候使用。
models:String[]
Array of models to require from appName.model namespace,for example:
models的数组值需要来自appName.model命名空间,例如:
Ext.define('MyApp.controller.Foo',{
extend:'Ext.app.Controller',
models:['User','Vehicle']
});
This is equivalent of:
这相当于:
Ext.define('MyApp.controller.Foo',{
extend:'Ext.app.Controller',
requires:['MyApp.model.User','MyApp.model.Vehicle']
});
name:String
The name of your application,this will also be the namespace of your views ,controllers,models and stores,dont’t use spaces or special characters in the name.
程序的名称,同时也是该程序下views,controllers,models,stores的命名空间目录。不能使用空格和特殊字符。
scope:Object
The scope to execute the launch function in,Defaults to the application instance.
launch函数的执行范围,默认本程序。
属性:
launch:Function
Called automatically when the page has completely loaded.This is an empty Function that should be overridden by each application that needs to take action on page load.
页面完全加载后执行。需要哪些想要页面加载后执行操作的程序覆盖。