调用方法报错,大神帮忙看看

代码如下,是读取JSON后
loadPlayerInfo是用来解析数据的,调用loadPlayerInfo报错
import Global from “./Global”;

const {ccclass, property} = cc._decorator;

@ccclass
export default class Common extends cc.Component {

public onLoad(){
    this.init();
}

public init(){
    cc.log("common onload");
    cc.loader.loadResDir("data",this.completeCallback);
}

public completeCallback(error: Error, resource: any[], urls: string[]){
    if (error) {
        cc.log("error:"+error);
    }else{
        for (let index = 0; index < resource.length; index++) {
            let element = resource[index];
            cc.log("completeCallback:"+element.name);
            if(element.name == "player"){
                cc.log("choice"+element.name);
                this.loadPlayerInfo(element);
            }
            //cc.director.loadScene("Game");
        }
    }
}

public loadPlayerInfo(element){
     cc.log("completeCallback:"+element.name);
    let attack : number = element.json.playerinfo.default.attack;
    let defence : number = element.json.playerinfo.default.defence;
    let hp : number = element.json.playerinfo.default.hp;
    let hp_max : number = element.json.playerinfo.default.hp_max;
    Global.PlayerInfo = [attack,defence,hp,hp_max];
}

}

报错如下
Common.ts:25
TypeError: Cannot read property ‘loadPlayerInfo’ of undefined
Common.ts:26
at Common.completeCallback (d:\wxgame_release\zombie\assets\Script\Common.ts:26:26)
at http://localhost:7456/app/engine/bin/cocos2d-js-for-preview.js:20253:29
at CCLoader. (http://localhost:7456/app/engine/bin/cocos2d-js-for-preview.js:20212:20)
at http://localhost:7456/app/engine/bin/cocos2d-js-for-preview.js:20084:37
at http://localhost:7456/app/engine/bin/cocos2d-js-for-preview.js:29351:11

请各路大神帮忙

:sweat_smile:好好看报错信息TypeError: Cannot read property ‘loadPlayerInfo’ of undefined
Common.ts:26。this指向问题

不太明白。。请指点

这种回调中不能使用this,定义一个全局的变量将this赋值给他,然后再回调中使用定义的变量代替this

在cc.Class 前边,也就是代码第一行添加 var _self=null; 在onLoad中赋值 _self=this; this.loadPlayerInfo()改为_self.loadPlayerInfo

多谢解答!!!明白意思了!