简体   繁体   English

对象# <Object> 应用程式init上没有方法&#39;getStore&#39;

[英]Object #<Object> has no method 'getStore' on the app init

I'm trying to get Store in the view on the init of the applicatoin, however the console tells me: Object #<Object> has no method 'getStore' 我试图在应用程序的初始化视图中获取Store,但是控制台告诉我: Object #<Object> has no method 'getStore'

I'm wondering how would you get a store in this sequence: 我想知道您将如何按以下顺序获得商店:

  1. Initialise app 初始化应用
  2. Get user GPS location 获取用户GPS位置
  3. Create a store 建立店铺
  4. Display view with the store 在商店中显示视图
init: function () { 
        this.callParent();
        console.log("controller init");
    },
    launch: function () {
        this.getApplicationSettings();
        this.getApplicationRegionalisation();
        Ext.getStore("appSettings").setValue("region", "Melbourne");

        var store = Ext.create("APN.store.Locations");
        var geo = Ext.create('Ext.util.Geolocation', {
            autoUpdate: false,
            listeners: {
                locationupdate: function(geo) {
                    var location = store.getClosestLocation(geo.getLatitude(), geo.getLongitude());
                    Ext.getStore("appSettings").setValue("region", location.get("location"));
                },
                locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
                }
            }
        });

And then in the view I would like to call something like this, correct me if I'm doing a stupid thing: 然后在视图中,我想调用这样的名称,如果我做的是愚蠢的事情,请纠正我:

requires: [
        'APN.store.AppSettings'
    ],
..... omitted stuff

// in items:
        items: [
            {
                itemId: 'nav_home',
        id: 'homeView',
                group: '',
                title: "Home",
                layout: 'vbox',
                slideButton: { selector: 'toolbar' },
                settingsButton: { selector: 'toolbar' },
                items: [{
                   xtype: 'articlelist',
                   id: 'latestNews',
                   category: 'Latest',
                   feedUrlName: 
// here is the place where it bugs out!
Ext.getStore("appSettings").getValue(Ext.getStore("appSettings").getValue("region").get("menuItems").home.url,
               }
                ],
            },

Wherever you are creating the view, you can create the store before that and set store to the view explicitly so that when initialize function is executed it will get this.config.store . 无论在何处创建视图,都可以在此之前创建存储,并将显式设置为该存储,以便在执行初始化函数时将获得this.config.store To get GPS location on app initialization, you can get location in Launch function of Ext.application before even creating the store and view. 要在应用初始化时获取GPS位置,您甚至可以在创建商店和视图之前在Ext.application Launch功能中获取位置。 If you want to create view only after store data is loaded, you should create view in load callback of store. 如果只想在加载商店数据后创建视图,则应在商店的加载回调中创建视图。

I hope this is what you were looking for, if not please add some code to your question so that we can comment on specifics. 我希望这是您想要的,如果没有,请在您的问题中添加一些代码,以便我们对具体内容发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Extjs getStore()方法的5种奇怪行为 - Extjs 5 strange behavior of the getStore() method 未捕获的TypeError:对象# <Object> 没有方法&#39;getValue&#39; - Uncaught TypeError: Object #<Object> has no method 'getValue' 对象没有方法getId sencha - Object has no method getId sencha Ext对象没有方法要求 - Ext object has no method require 对象函数没有方法延迟 - Object function has no method defer Javascript-Sencha touch 2.1-调用app.js级别的函数将返回“ [[Object Object]没有方法&#39;getLocalLoggedUserDetails&#39;”” - Javascript - Sencha touch 2.1 - Calling an app.js level function returns “[object Object] has no method 'getLocalLoggedUserDetails'” 未捕获的TypeError:对象[object Object]没有方法&#39;onAdded&#39; - Uncaught TypeError: Object [object Object] has no method 'onAdded' Sencha Touch错误:对象没有方法getShowInLegend - Sencha Touch error: object has no method getShowInLegend 未捕获的TypeError:对象# <YYY> 没有方法“ xxx” - Uncaught TypeError: Object #<YYY> has no method 'xxx' ExtJs 面板 ViewModel getStore() 调用返回 null 而不是返回本地 ajax 商店 object 与 URL 绑定到 ViewModel 数据成员 - ExtJs panel ViewModel getStore() call returns null instead of returning local ajax store object with URL bound to ViewModel data member
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM