React Native 是否会将 JavaScript 编译成 Java for Android? [英] Does React Native compile JavaScript into Java for Android?

查看:24
本文介绍了React Native 是否会将 JavaScript 编译成 Java for Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 React Native 开发混合应用程序时.当我从 React Native 代码创建 Android 应用程序时,我编写的 JavaScript 代码是否会转换为 Dalvik/ART 运行时的 Java 代码或 Java 字节码?还是只是将 UI 组件编译成原生 UI 组件?还是像 Fetch API 这样的库将 JavaScript 代码编译成 Java-Code 或 Java-Bytecode?

When I develop hybrid apps with React Native. Does the JavaScript code I write transform into Java-Code or Java-Bytecode for the Dalvik/ART Runtime when I create an Android-App from my React Native code? Or are just the UI components compiled into native UI components? Or does a library like the Fetch API compile the JavaScript code into Java-Code or Java-Bytecode?

推荐答案

基本上,您编写 Javascript.Javascript 与原生组件(Android 上的 Java、iOS 上的 Objective C、Windows 上的 C#)通信.

Basically, you write Javascript. The Javascript communicates with native components (Java on Android, Objective C on iOS, C# on Windows).

通信是通过所谓的桥"发生的.如果在任何时候您觉得这种通信速度太慢,您可以选择分别在 Java、Objective C 或 C# 中实现 Javascript 功能,以便纯原生运行.在这种情况下,您直接使用本机代码编写,因此本机编译不需要 Javascript.

The communication occurs through the so-called "bridge". If at any time you feel that this communication slows things down too much, you can choose to implement the Javascript functionality in Java, Objective C, or C# respectively in order to run purely native. In this case, you are writing directly in native code, so there's no Javascript to native compilation.

这将牺牲性能的兼容性.通常,这不是必需的.

This will sacrifice compatibility for performance. Normally, this is not necessary.

  • 进一步阅读

了解 React Native 桥接概念

这篇关于React Native 是否会将 JavaScript 编译成 Java for Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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