为什么会出现undefined

mushu:number;

start () {

    this.mushu=0;
    this.zifuchuanfenge();

}
zifuchuanfenge(){

    cc.loader.loadRes("wenben", function (err, conf) {

        if (err) {

            cc.error(err.message);

            return;

        }

        this.wenben=conf.toString();



        let qiege:string[]=[];

       //this.mushu 会显示undefined    
        let qie:string= this.wenbenArr[this.mushu];//如果吧this.mushu换成0  就不会显示undefined

        qiege=qie.split(",");

        cc.log(qiege.length);

        cc.log(this.mushu);



    });


这个地方加个 .bind(this) 试一下

还是不行。。

使用 => 箭头函数试下;
cc.loader.loadRes(“wenben”, (err, conf) => {

loader.load("", type, (err,assets)=>{//这就可以直接为所欲为使用 this. 你的成员比变量和方法了})

试过了还是不行

好像还是不可以

cc.loader.loadRes之前加var self = this,里面用self呢?

你打印看下这conf是啥东西

conf 获取 json 文件里面的字符

试下在loadres前面
let temp = this.mushu;
然后loadres里面用temp