我正在学习Angular 5,在学习组件交互部分时,遇到了以下内容
// Redefine `seconds()` to get from the `CountdownTimerComponent.seconds` ...
// but wait a tick first to avoid one-time devMode
// unidirectional-data-flow-violation error
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0);
我已经查阅了文档并在网上尝试寻找,但没有关于这个主题的清晰解释。请问有人能够解释一下吗?
- 这个“tick”是什么?
- 为什么我们需要它?
- 什么是单向数据流违规错误?
- setTimeout如何防止它?
- 还有其他方法可以预防吗?