【问题标题】:Specified store not found sencha touch未找到指定商店 煎茶触摸
【发布时间】:2023-03-28 20:15:01
【问题描述】:

我正在使用 MVC 架构将数据加载到列表中,并将其显示在屏幕上。 运行应用程序时出现以下错误

[WARN][test.view.list#applyStore] 找不到指定的Store

我尝试按照here 给出的说明进行操作,但它给了我错误:

在 null/view/list.js 处找不到文件 null/store/list1store.js null/model/list1modeljs

应用程序的根目录是“test”。

列出模型文件:

Ext.define('test.model.list1model', {
extend: 'Ext.data.Model',
config: {
    fields: [
        {name: 'firstName', type: 'string'},
        {name: 'lastName',  type: 'string'},
        {name: 'age',       type: 'int'},
        {name: 'eyeColor',  type: 'string'}
        ]
    }
});

列出存储文件:

Ext.define("test.store.list1store", {
extend:'Ext.data.Store',
requires:['test.model.list1model'],
config:{
  model: "test.store.list1model",
data : [
    {firstName: "Ed",    lastName: "Spencer"},
    {firstName: "Tommy", lastName: "Maintz"},
    {firstName: "Aaron", lastName: "Conran"},
    {firstName: "Jamie", lastName: "Avins"}
]
}
});

列表视图文件:

Ext.define("test.view.list", {
extend:'Ext.List',
requires:['test.store.list1store'],
config:{fullscreen: true,
store: 'test.store.list1store',
itemTpl: "{lastName}, {firstName}"
}
});

app.js:

Ext.application({
requires: [
'Ext.dataview.List',
'Ext.Panel',
 'Ext.Spacer',
  'test.view.list',
  'Ext.List',
  'test.model.list1model',
  'test.store.list1store'
],
launch : function(){
    list1 =Ext.create('test.view.list');
    Ext.create('Ext.Container',{
      id:'contain',

      fullscreen:true,
      items:[
    list1,
      ]
    })
  }
});

【问题讨论】:

    标签: list extjs model-view-controller store


    【解决方案1】:

    您只定义了一个 Store,但没有实例化它。请尝试以下操作:

    Ext.define("test.view.list", {
        extend:'Ext.List',
        requires:['test.store.list1store'],
        fullscreen: true,
    
        constructor : function() {
            this.callParent();
            this.setStore(Ext.create("test.store.list1store"));
        },
    
        config: {
            fullscreen: true,
            itemTpl: "{lastName}, {firstName}"
        }
    
    });
    

    PS:将商店中的模型更正为:model: "test.model.list1model"

    【讨论】:

    • 感谢您到目前为止的帮助,所有错误都已删除,但列表中未填充数据。
    • :) 好吧,现在数据已在您的商店中定义,我使用setStore() 方法。但是 store 的任务是多方面的:还要定义代理、模型、数据、过滤器……
    • 让我们清理 cmets。 PS:我认为在 Sencha Touch 中它可以与 ExtJS 类似地工作,但商店是不同的。
    • 如果你想玩得很快,看看哪些有效,哪些无效,请查看fiddle.sencha.com
    猜你喜欢
    • 2015-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-27
    • 2011-12-25
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多