当我上课时:
class DialogueChoice
{
constructor(text, resultFunc) //dialogue line text, function to call when selected
{
this.integer = 25;
...
}
test()
{
console.log(typeof(this.integer))
}
}
调用 test() 时,我得到的类型是未定义的,而不是数字。为什么是这样?我缺少什么?其他成员也会发生这种情况。据我所知,该类在构造函数之后丢失了所有成员?尝试打印该值也会导致未定义。仅当通过 pixjs 事件系统调用 func 时才会出现此问题。从脚本主体调用就可以了。
你如何使用你的课程,因为对我来说它似乎按预期工作?
class DialogueChoice
{
constructor(text, resultFunc) //dialogue line text, function to call when selected
{
this.integer = 25;
}
test()
{
console.log(typeof(this.integer))
}
}
var dc = new DialogueChoice();
dc.test();