在视图中显式实例化存储时出错

时间:2014-01-31 04:46:45

标签: javascript extjs

我有这样的观点:

Ext.define('MyApp.view.CustomersList', {
    extend: 'Ext.grid.Panel',

    store: Ext.create('MyApp.store.Customers'),

    columns: [
        {
            width: 150,
            dataIndex: 'customerName',
            text: 'CustomerName'
        },
        {
            width: 200,
            dataIndex: 'customerNumber',
            flex: 1,
            text: 'CustomerNumber'
        }
    ]
});

我明确地实例化了一个商店,但是当我在Viewport中加载这个视图时,我发现了这样的错误:

Uncaught TypeError: Expecting a function in instanceof check, but got function constructor() {
        // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to
        // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.
        return this.constructor.apply(this, arguments) || null;
    } 

Uncaught TypeError: Expecting a function in instanceof check, but got function constructor() {
        // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to
        // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.
        return this.constructor.apply(this, arguments) || null;
    } 

1 个答案:

答案 0 :(得分:2)

    Ext.define('MyApp.view.CustomersList', {
      extend: 'Ext.grid.Panel',

      initComponent: function(){
      this.store = Ext.create('MyApp.store.Customers');

      this.columns = [
      {
        width: 150,
        dataIndex: 'customerName',
        text: 'CustomerName'
      },
      {
        width: 200,
        dataIndex: 'customerNumber',
        flex: 1,
        text: 'CustomerNumber'
      }]
    this.callParent();
   }
   });

希望它有所帮助!!