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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值