[]关于类中方法的调用

var FactionListItem = (function(_super){
    function FactionListItem(data) {
        FactionListItem.super(this);

    
        this.updateLvAndPeopleCount();

        this.updateLvAndPeopleCount = function(){
        //-----
        }

    }
    Laya.class(FactionListItem,"FactionListItem",FactionMainNodeUI);

    return FactionListItem;
})();
 
 
 
在一个类里。。我可以用this.这样直接调用方法吗?我现在调用了会报错?
已邀请:

ymsdandan

赞同来自:

如果你怕执行域出错,可以用回调监听来调用

15818760256

赞同来自:

上传一个demo。。麻烦看下。。谢谢~

Monica - 知识达人

赞同来自:

语法问题,建议你先了解下js的基础语法(语法和项目逻辑我们一般不会在论坛上进行解答)
修改之后的代码:
var NpcLayer = (function(_super){
var m_talkScroll;

function NpcLayer(addrid) {
NpcLayer.super(this);

//文字滚动
// m_talkScroll = new UIScroll(610.0, 250);
// m_talkScroll.pos(0, 0);
// this.addChild(m_talkScroll);

// this.onAction();
// this.onAction = function(){
// console.log("-------------hhhhhhhhhhh ");
// }

//第一种解决方法
onAction();
function onAction(){
console.log("这是第一种解决方法");
}

//第二种解决方法
this.onAction();
}
Laya.class(NpcLayer,"NpcLayer",_super);
NpcLayer.prototype.onAction = function(){
console.log("这是第二种解决方法");
}

return NpcLayer;
})(Laya.Sprite);

要回复问题请先

商务合作
商务合作