Extjs 4 MVC 例子

Sencha Docs ExtJs 4.0 MVC例子

 

目录结构如下:

 

MVC目录

 

代码:index.html

<html>
  <head>
     <title>Account Manager</title>
     <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css">
     <script type="text/javascript" src="../../bootstrap.js"></script>
     <script type="text/javascript" src="app.js"></script>
  </head>
  <body>
  </body>
</html>

 

app.js

Ext.onReady(function(){
   Ext.QuickTips.init();
   //Uncaught Ext.Error: Ext.Loader is not enabled...
   Ext.Loader.setConfig({
      enabled:true
   });
   
   Ext.application({
    name: 'AM',

    appFolder: 'app',

    launch: function() {
        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: [
                {
                    xtype: 'panel',
                    title: 'Users',
                    html : 'List of users will go here'
                }
            ]
        });
    },
    controllers:[
       'UsersControl'   //请注意此处
    ]
});

});
 

UsersControl.js

Ext.define('AM.controller.UsersControl',{
   extend: 'Ext.app.Controller',
   init:function(){
      console.log('Initialized Users!');
   }
});

 

待续..

 

 

你可能感兴趣的:(ExtJs)