【发布时间】:2021-11-18 03:34:45
【问题描述】:
我似乎无法弄清楚为什么第一个 console.log 正确显示参数但第二个显示未定义。
控制台日志输出:
text
undefined
代码:
ngOnInit() {
this.getPuzzle();
}
getPuzzle() {
this.restProviderService.getPuzzle(this.gameService.getGameId()).subscribe(puzzle => {
this.puzzleType = puzzle.type;
this.puzzleValue = puzzle.value;
console.log(this.puzzleType);
setTimeout(this.handlePuzzle , 3000);
});
}
handlePuzzle() {
console.log(this.puzzleType);
if (this.puzzleType == 'text') {
new Vara("#text", "assets/fonts/vara/Satisfy/SatisfySL.json", [{
text: 'hello',
delay: 2000,
x: 2
}], {
fontSize: 25,
strokeWidth: 1.5,
duration: 5000,
color: "black"
});
}
}
【问题讨论】:
标签: javascript angular typescript ionic-framework rxjs