gpt4 book ai didi

cordova - React-Native 和 Cordova 之间的技术差异

转载 作者:行者123 更新时间:2023-12-02 02:03:43 26 4
gpt4 key购买 nike

“react-native”和“Apache Cordova”之间的技术差异是什么?

我已经使用 Cordova 一段时间了,它的工作方式是,它创建一个 webview( headless 浏览器)并通过各种 API 访问在其中运行应用程序。我一直想知道“react-native”是否也是如此。 “react-native”也会创建webview吗?或者它是否将 javascript 代码转换为 native 代码?

如果它创建像Cordova一样的“webview”,那么“Cordova + React”应用程序和“react-native”应用程序(不包括react-native提供的 native 组件)有什么区别?

我知道这里已经有此类问题的答案:Phone gap vs React Native 。但我的问题有点不同。谢谢。

最佳答案

Does "React-Native" also create webview?

没有。 React Native 是为 Android 和 IOS 编写 native 用户界面的抽象。您的 Javascript 代码在操作系统上的 Javascript 运行时中运行,但 UI 呈现为 native 组件。这使得它与 Cordova/PhoneGap 有很大不同。

React Native webpage 中提到了这一点:

Native Components

With React Native, you can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.

并在this blog post中有更详细的解释。 :

Since React components are just pure, side-effect-free functions that return what our views look like at any point in time, we never need to read from our underlying rendered view implementation in order to write to it. In the browser environment, React is non-blocking with respect to the DOM, but the beauty of React is that it is abstract and not tightly coupled to the DOM. React can wrap any imperative view system, like UIKit on iOS, for example.

So this means with a bit of work, we can make it so the exact same React that's on GitHub can power truly native mobile applications. The only difference in the mobile environment is that instead of running React in the browser and rendering to divs and spans, we run it in an embedded instance of JavaScriptCore inside our apps and render to higher-level platform-specific components.

关于cordova - React-Native 和 Cordova 之间的技术差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38128899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com