谷歌浏览器开发者工具中网络栏status=canceled 取消状态
今天在调试一个 react-player 的程序时候,浏览器里会出现一个(canceled)状态
stackoverflow上的解释
在爆栈网(stackoverflow)上找到了一个解释:
导致这一现象的原因可能是下面三个:
- The DOM element that caused the request to be made got deleted (i.e. an IMG is being loaded, but before the load happened, you deleted the IMG node)
- You did something that made loading the data unnecessary. (i.e. you started loading a iframe, then changed the src or overwrite the contents)
- There are lots of requests going to the same server, and a network problem on earlier requests showed that subsequent requests weren’t going to work (DNS lookup error, earlier (same) request resulted e.g. HTTP 400 error code, etc)
翻译一下
- DOM 元素还在请求网络的时候就被删除了;(比如图片在加载的过程中)
- 你做了一些操作使加载变得不必要的;(如你改变了正在加载的iframe 的src);
- 有许多请求一起请求相同的服务器,但是一个较早前报错的请求出现了,使得随后的请求不会正常起作用。
但是我的问题不在其中,我是通过(jquery)监听元素的点击事件,然后给它一个回调函数,并在该函数中添加
我的场景
react-player
在react18
的strict mode
里第2次会加载失败,导致视频无法加载
github解决方案
讨论的情况及解决方案,基本就是把
strict mode
给关掉
- https://github.com/cookpete/react-player/pull/1360
- https://github.com/cookpete/react-player/issues/1530