什么是“远程调试JS”?在干嘛 [英] What is "Debug JS Remotely" doing?

查看:176
本文介绍了什么是“远程调试JS”?在干嘛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释使用远程调试JS运行该应用程序与不使用该应用程序的行为有何不同?目前,我的应用在这两种模式下的行为似乎有所不同。

Can anyone explain how is it that running the app with "Debug JS Remotely" behaves differently than without it? Currently, my app seems to behave differently between these two modes.

具体来说,当我的应用位于远程调试JS中时,它可以触发API请求并获取响应成功。当应用不在远程调试JS中时,无法触发API请求?

To be specific, when my app is in "Debug JS Remotely", it can fire API requests and get responses successfully. When the app is not in "Debug JS Remotely", it's unable to fire API requests?

推荐答案

您遇到的问题可能是由于所涉及的Javascript引擎不同所致:

The issue you're experiencing might be due to the different Javascript engines involved:


  • 在设备上运行时,您的代码将在与RN应用本身捆绑在一起的JavascriptCore引擎上运行。

  • 在运行远程调试器,您的代码将在Chrome的V8引擎上运行,而不是在设备上运行。

不同的环境可能会有不同的行为。从此文章

Different environments might behave differently. Take the following example from this 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 而不是使用本机访存)。

For this reason, I prefer to sometimes use third-party implementations of some native features (like whatwg-fetch instead of using native fetch).

资源:

  • React Native Architecture - Javascript VM

这篇关于什么是“远程调试JS”?在干嘛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆