如何制作“MVC应用程序”与extjs 4.0 beta 3? [英] how to make a "MVC Application" with extjs 4.0 beta 3?

查看:115
本文介绍了如何制作“MVC应用程序”与extjs 4.0 beta 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人在这里使用EXTJS 4 BETA 3制作MVC应用程序?工作正常吗
请帮助我如何?..



我一步一步地遵循了 here ..和@Abdel Olakara帮助



但是仍然是一个错误...在这里我的firebug

  [Ext.Loader]同步加载AM.controller.Users;考虑添加
Ext.require('AM.controller.Users')在Ext.onReady

[Ext.Loader]同步加载'AM.store.Users';考虑添加
Ext.require('AM.store.Users')以上Ext.onReady

this.getView('Viewport')为null

当我阅读这个在论坛...还有一些与MVC指南的错误...



所以,如果你让它工作..怎么样?



这是我的 Application.js

  Ext.Loader.setConfig({启用:真}); 
Ext.create('Ext.app.Application',{
name:'AM',

controllers:[
'Users'
] ,

视图:[
'user.List'
],

启动:function(){
Ext.create Ext.container.Viewport',{
layout:'fit',
items:{
xtype:'userlist'
}
});
}
});

我试图在Extjs中学习MVC ...
抱歉,如果我的英文不好

解决方案

嗯,我想我应该收回我的话!经过sencha博客后,我取得了一些成功。最后,让我的MVC骨架运行!



这是工作代码:

  Ext.Loader.setConfig ({启用:真}); 
Ext.create('Ext.app.Application',{
name:'AM',
autoCreateViewport:false,
controllers:[],

launch:function(){
Ext.create('Ext.container.Viewport',{
layout:'fit',
items:[
{
xtype:'panel',
title:'Users',
html:'用户列表将在这里'
}
]
});
}
});

请注意,代码非常小,已删除常见在论坛和这里报告的错误。下一步是开始玩这个代码,并添加控制器,视图等!



我将继续更新此答案。






更新:提到的前两个错误实际上不是错误。他们是警告和应用程序工作正常,即使他们显示这些警告。你提到的第三个错误是一个塞子!



Viewport问题解决方案有两种解决方法。


  1. 使用 autoCreateViewport:false,属性并定义您的视口(我看到您已经在启动方式中定义了您的视口)

  2. 创建一个Viewport.js并将其保存在视图文件夹中。在这种情况下,我觉得我的启动方法为空,并将视口代码移动到Viewport.js文件。但是我收到一个错误:



    未捕获TypeError:无法调用方法'create'为null



Is there someone here who made a MVC application using EXTJS 4 BETA 3? and works fine?? please help me how?, ..

I have followed step by step here .. and @Abdel Olakara help

but there is still an error ... here my firebug

[Ext.Loader] Synchronously loading 'AM.controller.Users'; consider adding  
Ext.require('AM.controller.Users') above Ext.onReady  

[Ext.Loader] Synchronously loading 'AM.store.Users'; consider adding  
Ext.require('AM.store.Users') above Ext.onReady

this.getView('Viewport') is null

When i read this at the forum ... there are still some bug with MVC guide ...

so, if you ever make it works.. how?

this is my Application.js :

Ext.Loader.setConfig({enabled:true}); 
Ext.create('Ext.app.Application', {
    name: 'AM',

    controllers: [
        'Users'
    ],

    views: [
        'user.List'
    ],

    launch: function() {
        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: {
                xtype: 'userlist'
            }
        });
    }
});

i'm trying to learn MVC in Extjs... sorry if my english bad..

解决方案

Well, I think I should take back my words! I had some success after going through sencha blog. And finally, got my MVC "Skeleton" running!

Here is the working code:

Ext.Loader.setConfig({enabled:true});
Ext.create('Ext.app.Application', {
    name: 'AM',
    autoCreateViewport: false,
    controllers: [],

    launch: function() {
        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: [
                {
                    xtype: 'panel',
                    title: 'Users',
                    html : 'List of users will go here'
                }
            ]
        });
    }
}); 

Please note that, the code is very minimal and have removed the common errors reported in forums and here. The next step would be to start playing with this code and add controllers, views etc onto it!

I will keep updating this answer going forward.


Update: The first two error mentioned are not actually errors. They are warnings and application works fine even if they display these warnings. The third error you mentioned is a stopper!

Solution to Viewport problem Here are two ways to solve it.

  1. Use the autoCreateViewport: false, property and define your viewport (I see that you have defined your viewport in launch method)
  2. Create a Viewport.js and save it in view folder. In this case, I felt my launch method empty and moved the viewport code to Viewport.js file. But I do get an error:

    Uncaught TypeError: Cannot call method 'create' of null

这篇关于如何制作“MVC应用程序”与extjs 4.0 beta 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆