sencha touch Ext.Ajax.request 错误 Cannot call method 'request' of undefined 解决方案

凡是Cannot call method '' of undefined 这类错误大部分都可以参照下面的办法来解决

在st中有时候你会发现使用Ext.Ajax.request会出现一下错误:

 Cannot call method 'request' of undefined

出现以上错误的原因是Ext.Ajax这个组件没有被注册

解决方案:

1.一般来说你只要在控制层或者app.js注册引用了model、store,st就会自动注册主键

代码如下:

 1 /*
 2 *列表控制
 3 */
 4 Ext.define('app.controller.List', {
 5     extend: 'Ext.app.Controller',
 6     config: {
 7         models: ['Blog', 'Quiz'],
 8         stores: ['BlogList', 'QuizList'],
 9         views: ['list.Home'],
10         refs: {
11             listHome: 'listHome'
12         },
13         control: {
14             listHome: {
15                 itemtap: function (list, index, target, record, e) {
16                     this.redirectTo('redirec/' + record.get('redirect'));
17                     util.storeLoad(record.get('store'));
18                 }
19             }
20         }
21     }
22 });

2.如果不使用model、store

可以直接注册组件

1 Ext.application({
2     name: 'app',
3     appFolder: 'app',
4     controllers: ['Main', 'Panel', 'Layout', 'List'],
5     requires: ['Ext.Ajax'],
6     launch: function () {
7         util.inIt();
8     }
9 });

3.通过Ext.require方法注册

1         Ext.require('Ext.Ajax', function () {
2             Ext.Ajax.request({
3             //代码省略
4         });
原文地址:https://www.cnblogs.com/mlzs/p/3415376.html