【问题标题】:Yelp API key not working in Sencha Architect demo codeYelp API 密钥在 Sencha Architect 演示代码中不起作用
【发布时间】:2014-07-23 03:32:13
【问题描述】:

我在这里使用教程:http://docs.sencha.com/architect/3/tutorials/first_mobile_application.html#The_Controller

getBusinesses: function(location, callback) {
    // Note: Obtain a Yelp API key by registering (for free)
    // with Yelp at http://www.yelp.com/developers/getting_started/api_overview
    // (in this app, we use the Review Search API v1.0)

    var store = Ext.data.StoreManager.lookup('BusinessStore'),
        yelpKey = '', // Enter your Yelp API key here
        url = 'http://api.yelp.com/business_review_search' +
        '?ywsid=' + yelpKey +
        '&term=Bars' +
        '&lat=' + location.coords.latitude +
        '&long=' + location.coords.longitude;

    store.getProxy().setUrl(url);


    store.load(function() {
        callback(store);
    });
}

我在 Yelp 上申请了一个 API 密钥,结果如下:

我不确定该使用哪一个。教程代码有一个占位符,如上面的代码所示

已完成的应用显示错误:Uncaught TypeError: Cannot read property 'setStore' of undefined at:

        me.getBusinesses(location, function (store) {

            // Bind data to the list and display it
            me.getDataList().setStore(store);

【问题讨论】:

    标签: extjs sencha-touch sencha-architect


    【解决方案1】:
    1. 您需要 API v1.0 密钥。
    2. getDataList() 返回 undefined 因为 View 不存在。您可能忘记在 ListContainer 中命名 List 视图,请参阅“列表视图 - 步骤 4”。此外,函数名称源自您在 *"The Controller - Step 7" 中设置的引用。将其命名为datalist 将使函数变为getDatalist(),而将其命名为dataList 将使其变为getDataList()。注意大写的“L”。

    希望这可以帮助其他遇到问题的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2018-10-12
      相关资源
      最近更新 更多