Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 未定义Ext.StoreManager.lookup中的查找_Extjs_Sencha Touch 2 - Fatal编程技术网

Extjs 未定义Ext.StoreManager.lookup中的查找

Extjs 未定义Ext.StoreManager.lookup中的查找,extjs,sencha-touch-2,Extjs,Sencha Touch 2,我的看法是: Ext.define('MyApp.view.Login.LoginForm',{ extend: 'Ext.form.Panel', alias: 'loginForm', requires: ['Ext.form.FieldSet', 'Ext.Img'], config: { items: [ { xtype: 'fieldset', ite

我的看法是:

Ext.define('MyApp.view.Login.LoginForm',{
    extend: 'Ext.form.Panel',
    alias: 'loginForm',
    requires: ['Ext.form.FieldSet', 'Ext.Img'],
    config: {
        items: [
            {
                xtype: 'fieldset',
                items: [
                    {
                        xtype: 'textfield',
                        name: 'username',
                        required: true
                    },{
                        xtype: 'textfield',
                        name: 'password',
                        required: true,
                        inputType: 'password'
                    },{
                        xtype: 'selectfield',
                       //*****************the problem is here****************
                        store: Ext.StoreManager.lookup('MyApp.store.Tables')
                        //store: Ext.StoreManager.lookup('Tables')
                    }
                ]
            },{
                xtype: 'button',
                text: 'Login',
            }
        ]
    }
});
它说它不能使用
查找未定义的
,所以我认为MyApp看不到Ext.StoreManager

我还尝试了
Ext.data.StoreManager.lookup
Ext.StoreMgr

顺便说一句,这家商店确实存在。

请尝试按照以下说明操作,并让我知道它是否有效:

  • 确保将商店包含在你的
    app.js
    文件中
  • Tables.js
    store实现文件中,在其配置中为其指定一个
    storeId
    ,如下所示:
    config:{storeId:'Tables'}
  • 使用此选项而不是Ext.StoreManager:
    store:'Tables'

  • 希望有帮助。

    您的商店配置应如下所示:

    Ext.define('MyApp.store.Tables', {
        extend: "Ext.data.Store",
        config: {
            model: "MyApp.model.Table",
            data : [{
                text: "Ed",    
                value: "Spencer"
            }, {
                text: "Tommy", 
                value: "Maintz"
            }]
        }
    });
    
    并将其放入您的LoginForm.js中:

    {
          xtype: 'selectfield',
          store: 'Tables'
    }
    

    我已经测试过了。工作正常。

    工作正常!非常感谢。还有一个问题,这是Sencha Touch 2还是ExtJS 4新版本中的变化?在ExtJS 4的早期版本中,我会查找store.Lol没关系,兄弟,抱歉我的简短:)关于你关于storeId的问题,是的,它在这种情况下仍然有效,因为在命令
    store:'Tables'
    后面,Sencha Touch会查找相应的类名,即
    yourApp.store.Tables
    。但是如果有时您想直接通过这个
    Ext.getStore('Tables')
    Ext.getStore
    是您以前尝试使用的
    Ext.data.StoreManager.lookup
    的简写形式,则不会这样做,这就是为什么我提到了
    storeId
    ;)@泰姆:我想纠正你,先生。你的最后一行错了
    Ext.getStore('Tables')
    在没有
    storeId
    的情况下也可以工作。@AnandGupta:它可能会工作,但只有在这种情况下:定义没有storeId的存储,然后使用
    Ext.getStore()
    并传递由框架本身创建的存储的指定id,在本例中为“Tables”。如果您将storeId更改为smt-else,比如“store.Tables”,Ext.getStore(“Tables”)将返回
    undefined
    ,并且在所有情况下,都不依赖于框架创建的默认id的存在。相反,显式声明重要配置总是更好的做法,对吗?