0

こんにちは私のコードを実行した後にこのエラーが発生します。「UncaughttypeError:Undefinedのプロパティ'isModel'を読み取れません」と表示されます。「model.login」という名前の定義済みモデルとダミーデータのあるストアを使用してリストを表示しようとしています。

Ext.Loader.setConfig({
enabled: true,
paths:{
    'model' : 'app/model',
    'store' : 'app/store'
}

});
Ext.application({
    name: 'GS',
    launch: function(){
        var myStore = null;
        Ext.require('model.login', function(){
            var login = Ext.create('model.login');
            myStore = new Ext.data.Store({
                model: login,
                data:[
                      {id:'09803' , issued_at: 'thisurl', instance_url:'https', signature:'token', access_token:'ser'}
                      ]
            });
        });
        this.viewport = new Ext.Panel({
            fullscreen: true,
            items:[
                   {
                       xtype: 'list',
                       itemTpl: '{id}',
                       store: myStore
                   }
                   ]
        });
    }

});
4

1 に答える 1

2

ビューポートを作成するための呼び出しmodel.loginは、ロードされてストアが作成される前に発生します。コードを移動して、のコールバックにビューポートを作成しますExt.require

また、モデルをストアに渡すときは、そのインスタンスではなく、モデルコンストラクターを渡します。

Ext.application({
  name: 'GS',
  launch: function(){
    this.viewport = 
    var me = this;
    Ext.require('model.login', function(){                
      myStore = new Ext.data.Store({;

      me.viewport = new Ext.Panel({
        fullscreen: true,
        // You can pass a single item into item
        items:{
          xtype: 'list',
          itemTpl: '{id}',
          store: myStore
        }
      });
    });
  }
});

これを行うためのより良い方法があることに注意してください。ロードするモデルをアプリケーションに指示し、呼び出しの一部をインライン化して読みやすくすることができます。

Ext.application({
  name: 'GS',
  models: 'login', // looks in GS.model.login
  launch: function(){
    me.viewport = new Ext.Panel({
      fullscreen: true,
      // You can pass a single item into item
      items:{
        xtype: 'list',
        itemTpl: '{id}',
        store: {
          model: 'model.login', // or GS.model.login without quotes
          data:[              
            {id:'09803' , issued_at: 'thisurl', instance_url:'https', signature:'token', access_token:'ser'}]
          }
       }
    });
  }
});
于 2012-10-16T22:56:31.357 に答える