关于Ext4的mvc模式构建前端界面的问题!reader.read is not a function
来源:互联网 发布:少年包青天1抄袭 知乎 编辑:程序博客网 时间:2024/05/16 09:35
原帖发表在我的baidu个人空间.
http://hi.baidu.com/kvkens/blog/item/d40f84946d6a7204d21b7096.html
原创!
==================================================================
一直按官方API给的例子在看MVC,一直没有成功,总是出问题,本地内存数据可以加载,但是官方的远程JSON一直是错误的,写普通的EXT可以加载,在MVC下就是无法加载,显示“reader.read is not a function”,大概的意思是读取函数不存在模型是空的,也就是说,model是未赋值的,不存在才出的错误,可是model是赋值的,很奇怪,后来百度无结果,ext4在国内资源讨论还是很少的,最后我在google的时候,看到Sencha官方forum的一个帖子,我才恍然大悟 http://www.sencha.com/forum/showthread.php?136484-quot-reader.read-is-not-a-function-quot-problem-in-firefox/page2 (reader.read is not a function" problem in firefox),说的是MVC的加载顺序问题,
and I understand I have to include my file in this order :
- app.js
- model.js
- store.js
- view.js
- controllers.js
otherwise I need to use Ext.require ...
很显然,我们的EXT4 MVC的加载顺序是这样子的,app->controller->view->store->model
看到没,最后是model ,但是store是需要加载model的,所以导致store要去加载model的时候,model不存在,解决方法就是在store里面添加引用requires: [ 'My.model.User']
这样,store就可以在加载之前把model提前读取来,就可以访问到了。
附一下修改后的代码:
Ext.define('AM.store.Users', {
extend : 'Ext.data.Store',
requires : [ 'AM.model.User' ],
model : 'AM.model.User',
autoLoad : true,
proxy : {
type : 'ajax',
api : {
read : 'data/users.json',
update : 'data/updateUsers.json'
},
reader : {
type : 'json',
root : 'users',
successProperty : 'success'
}
}
});
Ext.define('AM.store.Users', { extend : 'Ext.data.Store', requires : [ 'AM.model.User' ],//添加引用 model : 'AM.model.User', autoLoad : true, proxy : { type : 'ajax', api : { read : 'data/users.json', update : 'data/updateUsers.json' }, reader : { type : 'json', root : 'users', successProperty : 'success' } }});
- 关于Ext4的mvc模式构建前端界面的问题!reader.read is not a function
- ExtJS4 reader.read is not a function
- 关于js报$ is not a function 的问题
- 关于addClass is not a function问题的原因
- 学习Extjs MVC框架发现的问题——requires.push is not a function
- 关于pymongo中“False is not a read preference”问题的解决方案
- 关于jquery使用live()方法的问题Uncaught TypeError: $(...).live is not a function
- ucUncaught TypeError: window.showModalDialog is not a function关于showModalDialog停用的问题
- js报$ is not a function 的问题的解决方法
- $(document).ready is not a function的问题
- 出现$(#form).validate is not a function的问题
- $(document).ready is not a function的问题
- 出现$(#form).validate is not a function的问题
- 出现$(#form).validate is not a function的问题
- $(document).ready is not a function的问题
- 偶遇一次$(...).modal() is not a function的问题
- rvm is not a function的解决方法
- 前端插件之间面对重复使用规则的兼容转换---$(...).XXX is not a function
- 相亲相爱
- 手机游戏策划模版
- Fedora 14在笔记本上的安装日志
- Oracle11g,在SQL Developer里新建连接时出现错误(已解决)
- 什么是游戏策划,如何成为一名游戏策划
- 关于Ext4的mvc模式构建前端界面的问题!reader.read is not a function
- 今天和大家讲一下怎么样简单的把壁纸作为背景,在中间加一个textview效果图如下
- 今天开始阅读《现代操作系统》
- Java中的instanceof关键字
- 排序算法小结
- difference between Interface and abstract class in Java
- jquery 弹出一个淡出窗口示例代码
- MYSQl left join 联合查询效率分析
- usb Mass Storage