【发布时间】:2019-09-24 20:27:43
【问题描述】:
我正在尝试在我的 ionic4 应用程序中进行一些反应时间任务。基本上,页面是白色的,当用户准备好点击屏幕(屏幕改变颜色),然后当颜色再次改变时(随机时间后),我想得到时间。
html代码:
<ion-content (click)="changeColor()" >
</ion-content>
.ts 代码
changeColor() {
setTimeout(() => {
this.theme.enableColor('light-theme');
this.time1 = new Date().getTime();
}, this.randomTime);
this.changeColor2();
}
changeColor2() {
this.theme.enableColor('dark-theme');
}
主题是我的服务,我在其中创建了 enableColor,它只是一个更改 css 属性的函数。这可以正常工作。
因此,当我单击屏幕时,它会在随机时间后再次更改颜色,然后当我再次单击时,我希望屏幕再次更改颜色并找到用户反应的时间。
【问题讨论】: