"Debug JS Remotely" 在做什么?
What is "Debug JS Remotely" doing?
任何人都可以解释 运行 带有 "Debug JS Remotely" 的应用与没有它时的行为有何不同?目前,我的应用似乎在这两种模式下表现不同。
具体来说,当我的应用处于 "Debug JS Remotely" 时,它可以触发 API 请求并成功获得响应。当应用程序不在 "Debug JS Remotely" 时,它无法触发 API 请求?
您遇到的问题可能是由于涉及不同的 Javascript 引擎:
- 当 运行 在设备上运行时,您的代码将 运行 在 Javascript 与 RN 应用程序本身捆绑在一起的核心引擎上。
- 当 运行 启用远程调试器时,您的代码将 运行 在 Chrome 的 V8 引擎上,而不是在设备上。
不同的环境可能会有不同的表现。从这个article中拿下面的例子:
没有远程调试:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // 02/12/17
远程调试:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // Feb 12
出于这个原因,有时我更喜欢使用某些本机功能的第三方实现(例如 whatwg-fetch 而不是使用本机提取)。
资源:
您好,正如上面@Matei 所解释的您遇到的问题可能是由于涉及不同的 Javascript 引擎
在我的例子中,代码在调试模式下 运行 很好,但是一旦我关闭调试模式屏幕就会卡住
解决方法:
So what worked for me was removing all the console.log from the file.
So just remove all the console.log from your code and it will work like a charm.
任何人都可以解释 运行 带有 "Debug JS Remotely" 的应用与没有它时的行为有何不同?目前,我的应用似乎在这两种模式下表现不同。
具体来说,当我的应用处于 "Debug JS Remotely" 时,它可以触发 API 请求并成功获得响应。当应用程序不在 "Debug JS Remotely" 时,它无法触发 API 请求?
您遇到的问题可能是由于涉及不同的 Javascript 引擎:
- 当 运行 在设备上运行时,您的代码将 运行 在 Javascript 与 RN 应用程序本身捆绑在一起的核心引擎上。
- 当 运行 启用远程调试器时,您的代码将 运行 在 Chrome 的 V8 引擎上,而不是在设备上。
不同的环境可能会有不同的表现。从这个article中拿下面的例子:
没有远程调试:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // 02/12/17
远程调试:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // Feb 12
出于这个原因,有时我更喜欢使用某些本机功能的第三方实现(例如 whatwg-fetch 而不是使用本机提取)。
资源:
您好,正如上面@Matei 所解释的您遇到的问题可能是由于涉及不同的 Javascript 引擎 在我的例子中,代码在调试模式下 运行 很好,但是一旦我关闭调试模式屏幕就会卡住
解决方法:
So what worked for me was removing all the console.log from the file.
So just remove all the console.log from your code and it will work like a charm.