为什么我不能在ExtJs中使用存储的短名称

why I can't use short name of store in ExtJs?

本文关键字:存储 不能 ExtJs 为什么      更新时间:2023-09-26

我使用ExtJs 6.0.0 &Sencha Cmd 6.0.2和使用MVC架构,我有一个简单的应用程序由Sencha Cmd生成的测试如下:

//MyApp/商店/Personnel.js

Ext.define('MyApp.store.Personnel', {
  extend: 'Ext.data.Store',
  alias: 'store.personnel',
  fields: [
    'name', 'email', 'phone'
  ],
  data: {
    items: [{
      name: 'Jean Luc',
      email: "jeanluc.picard@enterprise.com",
      phone: "555-111-1111"
    }]
  },
  proxy: {
    type: 'memory',
    reader: {
      type: 'json',
      rootProperty: 'items'
    }
  }
});

//MyApp/app/视图/主/List.js

Ext.define('MyApp.view.main.List', {
  extend: 'Ext.grid.Panel',
  xtype: 'mainlist',
  requires: [
    'MyApp.store.Personnel'
  ],
  title: 'Personnel',
  store: 'Personnel',
  //store: {
  //    type: 'personnel'
  //},
  columns: [{
    text: 'Name',
    dataIndex: 'name'
  }, {
    text: 'Email',
    dataIndex: 'email',
    flex: 1
  }, {
    text: 'Phone',
    dataIndex: 'phone',
    flex: 1
  }],
  listeners: {
    select: 'onItemSelected'
  }
});

//MyApp/app/Application.js

Ext.define('MyApp.Application', {
    extend: 'Ext.app.Application',
    
    name: 'MyApp',
    stores: [
        // TODO: add global / shared stores here
        'Personnel'
    ]  
});

它是,我想在List的视图中使用Personnel商店的短名称(仅Classname与out命名空间),但它不起作用。但是在票务应用 (Sencha官方推荐的示例也在SDK中)它这样使用并且工作完美,为什么我的不能正常工作?

store: 'foo'表示id为foo的存储。该存储必须已经创建了一个实例。

您应该使用您在那里注释的type语法