【发布时间】:2022-01-26 02:33:27
【问题描述】:
尝试在画布中调用函数时出现错误core.js:6241 ERROR TypeError: this.test is not a function at klass.<anonymous>
HTML
<canvas #canvas id="canvas" width="900" height="400"></canvas>
ts
ngOnInit() {
this.cvs.on("stagemouse:down", function(){
console.log('Event mouse:down Triggered');
this.test();
})
}
test(){
console.log("test");
}
【问题讨论】:
-
尝试使用箭头函数定义,可能
this指的是画布而不是你的组件在这个上下文中
标签: angular typescript canvas