学习Extjs MVC框架发现的问题——requires.push is not a function
来源:互联网 发布:java拦截器权限管理 编辑:程序博客网 时间:2024/05/16 05:25
昨天在学习Extjs4时,按照文档的代码写了一遍,发现无法运行,代码如下:
app.js:
Ext.application({ requires: 'Ext.container.Viewport', name: 'AM', controllers: ['Users'], appFolder: 'app', launch: function() { Ext.create('Ext.container.Viewport', { layout: 'fit', items: [ { xtype: 'panel', title: 'Users', html : 'List of users will go here' } ] }); }});
User.js
Ext.define('AM.controller.Users', { extend: 'Ext.app.Controller', init: function() { this.control({ 'viewport > panel': { render: this.onPanelRendered } }); }, onPanelRendered: function() { console.log('The panel was rendered'); }});
index.htm
<html><head> <title>Hello Ext</title> <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"> <script type="text/javascript" src="extjs/ext-debug.js"></script> <script type="text/javascript" src="app.js"></script></head><body></body></html>
运行时,页面老是一片空白。用firebug调试发现,提示错误:
requires.push is not a function。
发现问题出在app.js: controller:['Users']上,一旦去掉这句话,页面是能出来的,一加上,问题就会出来。最后发现,extjs包里的Application.js运行app的代码如下:
var requires = config.requires || [], controllers, ln, i, controller, paths, path, ns;........if (this.autoCreateViewport) { requires.push(this.getModuleClassName('Viewport', 'view')); }.......
其中,config.requires就是app.js中requires属性,这里的变量requires是个数组,而我的app.js的requires属性配置不是数组,所以导致这里的变量requires=config.requires||[ ]变成了一个字符串,而不是数组,以致运行到requires.push的时候,提示这个function不存在,所以只要把app.js里,requires属性改成如下:
requires:['Ext.container.Viewport']
问题解决。
- 学习Extjs MVC框架发现的问题——requires.push is not a function
- ExtJs this.addevents is not a function
- 关于Ext4的mvc模式构建前端界面的问题!reader.read is not a function
- PHP_Laravel框架下datepicker is not a function的解决办法
- jQuery—$ is not a function
- JS中提示push is not a function
- JAVA学习(六)__$(document).ready is not a function的问题
- js报$ is not a function 的问题的解决方法
- $(document).ready is not a function的问题
- 出现$(#form).validate is not a function的问题
- $(document).ready is not a function的问题
- 关于js报$ is not a function 的问题
- 出现$(#form).validate is not a function的问题
- 出现$(#form).validate is not a function的问题
- 关于addClass is not a function问题的原因
- $(document).ready is not a function的问题
- 偶遇一次$(...).modal() is not a function的问题
- extjs中出现this.addevents is not a function错误
- 主成分分析(Principal components analysis)-最大方差解释
- select int 型数据,前面加0
- MFC OnCreateClient学习总结
- 详解 MySQL Replication Error 1032 & 1205
- 《Intel汇编语言程序设计》书中例子编译
- 学习Extjs MVC框架发现的问题——requires.push is not a function
- ibatis练习
- 重庆干旱致50万人饮水困难
- 程序员基本素质
- 对比的架构
- js验证表单
- 研究称水城威尼斯仍缓慢下沉 且发生倾斜
- python os.path常用模块
- 触发器-2