0

コードを Visualforce (動作中) から Lightning コンポーネントに移行しようとしています。update メソッドはグラフを描画し、ルート ノードが変更されたときに再描画する必要があります。メソッドを正しく宣言していると思いますが、「update」を呼び出すと上記のエラーが発生します。関数名が予約済みのキーワードである場合に備えて関数名を変更しようとしましたが、同じエラーが発生しました。助言がありますか??どうもありがとう

コードは次のようになります...

({
    doInit : function(component, event, helper) {

        var action = component.get("c.getNodeJSON");

        action.setCallback(this, function(response){       
            var data = JSON.parse(response.getReturnValue());
            component.set("v.root", data);
            update(component, root);
        });

        $A.enqueueAction(action);
    },

    update : function(component, source) {
        var root = component.get("v.root");
        // etc etc
    }
})
4

2 に答える 2

-1

update を直接呼び出すことはできません。update メソッドを呼び出す前に .this を追加する必要があります。以下の更新されたコードを試してください。

({ doInit : function(コンポーネント、イベント、ヘルパー) {

    var action = component.get("c.getNodeJSON");
    var self = this;
    action.setCallback(this, function(response){       
        var data = JSON.parse(response.getReturnValue());
        component.set("v.root", data);
        this.update(component, root);
    });

    $A.enqueueAction(action);
},

update : function(component, source) {
    var root = component.get("v.root");
    // etc etc
}

}))

これで問題が解決した場合は、正しい回答をしてください。

于 2015-10-06T07:07:34.973 に答える