【问题标题】:Object #<Object> has no method 'getStore' on the app init对象 #<Object> 在应用程序初始化时没有方法“getStore”
【发布时间】:2013-05-12 02:26:06
【问题描述】:

我试图在应用程序的 init 视图中获取 Store,但是控制台告诉我:Object #&lt;Object&gt; has no method 'getStore'

我想知道您如何按此顺序获得商店:

  1. 初始化应用
  2. 获取用户 GPS 位置
  3. 创建商店
  4. 显示与商店的视图
初始化:函数(){ this.callParent(); console.log("控制器初始化"); }, 启动:函数(){ this.getApplicationSettings(); this.getApplicationRegionalisation(); Ext.getStore("appSettings").setValue("region", "Melbourne"); var store = Ext.create("APN.store.Locations"); var geo = Ext.create('Ext.util.Geolocation', { 自动更新:假, 听众:{ 位置更新:功能(地理){ var location = store.getClosestLocation(geo.getLatitude(), geo.getLongitude()); Ext.getStore("appSettings").setValue("region", location.get("location")); }, 位置错误:函数(地理,bTimeout,bPermissionDenied,bLocationUnavailable,消息){ } } });

然后在视图中我想这样称呼,如果我在做一件愚蠢的事情,请纠正我:

要求:[ 'APN.store.AppSettings' ], .....省略的东西 // 在项目中: 项目: [ { itemId: 'nav_home', id: 'homeView', 团体: '', 标题:“家”, 布局:'vbox', 滑动按钮:{选择器:'工具栏'}, 设置按钮:{选择器:'工具栏'}, 项目: [{ xtype: '文章列表', id: '最新消息', 类别:“最新”, 提要网址名称: // 这里是它出错的地方! Ext.getStore("appSettings").getValue(Ext.getStore("appSettings").getValue("region").get("menuItems").home.url, } ], },

【问题讨论】:

  • 在哪一行出现错误?
  • 它在哪里说// here is the place where it bugs out 所以我理解当应用程序加载所有文件和compiles interprets 它们并看到Ext.Store 没有初始化,然后它加载控制器init 方法和控制器launch 初始化存储的方法

标签: extjs sencha-touch workflow


【解决方案1】:

无论您在哪里创建视图,您都可以在此之前创建存储并将存储显式设置为视图,以便在执行初始化函数时它会得到this.config.store。要在应用初始化时获取 GPS 位置,您可以在创建商店和视图之前在 Ext.application 的 Launch 函数中获取位置。如果你想在 store 数据加载后才创建 view,你应该在 store 的 load 回调中创建 view。

我希望这是您正在寻找的内容,如果不是,请在您的问题中添加一些代码,以便我们对细节发表评论。

【讨论】:

  • 刚刚更新,其实你给了我一点理解……但反正还在搜索中
猜你喜欢
  • 2013-07-20
  • 2010-09-13
  • 2010-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多