console.time("myTimer");for(var i=0;i这几乎就是你的代码在做什么.第一次 subscribe 被称为您的计时器输出自启动以来的时间量.在随后的 3 次调用中,它不起作用.此行为特定于 Chrome,它在 IE 和火狐浏览器.I've been created a demo for RxJS scan() method but unfortunately my timer doesn't work properly and I get this error: Timer 'myTimer' does not existconsole.time('myTimer');let source = Rx.Observable .interval(100) // interval starts from 0 .take(4) .scan((acc, val) => acc + val);source.subscribe((value) => { console.timeEnd('myTimer'); console.log('in next. Value: ', value);});Here is a demo in JSBin.Here is a source that I Copy code from that.How can fix that issue? 解决方案 Once you've stopped the timer with console.timeEnd("name") it no longer exists when using chrome.console.time("myTimer");for(var i=0;i<10000;i++){}console.timeEnd("myTimer"); // worksconsole.timeEnd("myTimer"); // displays an error (in chrome only)Which is pretty much what your code is doing. The first time subscribe is called your timer outputs the amount of time since it ws started. On the 3 subsequent calls it does not work.This behaviour is specific to Chrome, it works how you expect in both IE & Firefox. 这篇关于Console.timer() 中不存在 myTimer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-03 04:42