1

私は道場にかなり慣れていないので、コールバックを処理するために lang.hitch メソッドを使用しようとしていますが、使用すると「Uncaught Reference Error: is not defined error」というエラーが発生し続けます。私は何か間違ったことをしていると確信しています-それが何であるかはわかりません。 thisコードをステップ実行したときに検証された、i​​nitializeLocators 関数で新しく作成したオブジェクトを参照します。showResults メソッドへの候補パラメータは、イベント処理クロージャから返されます。ご協力いただきありがとうございます。

私のクラス:

define(["dojo/_base/declare", ..., "dojo/_base/lang", "dojo/on", "dojo/dom", ...], 
function(declare, ..., lang, ...){
    var SDCLocateClass = declare(null, {
        ...,
        constructor: function() {
            this.initializeLocators();
        },
        initializeLocators: function() {
            this.addressNode = dom.byId("resultsDiv");


            //set up the address locator functionality
            this.locator = new Locator("http://...");
            this.locator.on("address-to-locations-complete", lang.hitch(this, showResults));
        },
        showResults: function(candidates) {
            ...
        },
    });
    return SDCLocateClass;
});
4

1 に答える 1

2

showResults定義されていない変数です。文字列を使用this.showResultsまたは使用する"showResults"

this.locator.on("address-to-locations-complete", 
    lang.hitch(this, this.showResults));
于 2013-10-04T17:10:44.490 に答える