简体   繁体   English

与Cordova反应原生网络视图

[英]React native web-view vs Cordova

I have an app build using cordova. 我有一个使用cordova的应用程序构建。 However, making it look properly on android is being a bit though. 然而,让它在Android上正确看起来有点过分了。 I read reac-native documentation and I thought about combining the current state of the app, embedding it on a web view and building the rest of the app using react-native. 我阅读了反本地文档,并考虑将应用程序的当前状态组合在一起,将其嵌入到Web视图中,并使用react-native构建应用程序的其余部分。

The reason behind this is that I feel more comfortable building the android specific ui of the app (like sidebars, and menus) using react-native than cordova, and I want to know if this approach makes sense. 这背后的原因是我觉得使用react-native而不是cordova构建应用程序的android特定ui(比如侧边栏和菜单)更舒服,我想知道这种方法是否有意义。 Is react native web view as powerful as cordova? 反应原生网络视图与cordova一样强大吗? Does this make any sense? 这有道理吗?

Thanks and regards 谢谢并恭祝安康

Despite React Native owns a WebView component I believe that this component is not appropriate for your approach. 尽管React Native拥有一个WebView组件,但我认为这个组件不适合您的方法。

From the docs: 来自文档:

WebView renders web content in a native view. WebView以本机视图呈现Web内容。 You can use this component to navigate back and forth in the web view's history and configure various properties for the web content. 您可以使用此组件在Web视图的历史记录中来回导航,并为Web内容配置各种属性。

The purpose of React Native WebView is simply "renders web content". React Native WebView的目的只是“呈现Web内容”。

I believe that you can not simply put your current Cordova code inside a React Native Web View and "it works". 我相信你不能简单地将当前的Cordova代码放在React Native Web View中并且“它可以工作”。 If your current Cordova app is more than simple HTML pages and use some Cordova Plugin, for example, you will have problems at this point. 例如,如果您当前的Cordova应用程序不仅仅是简单的HTML页面并使用某些Cordova插件,那么您将遇到问题。

Added to this the fact that strange architecture will probably increase the maintenance cost. 除此之外,奇怪的架构可能会增加维护成本。

And about React Native to be as powerful as Cordova: I would say that React Native is more promising and very powerful, but actually Cordova has a ecosystem more mature and consistent. 关于React Native和Cordova一样强大:我会说React Native更有前途且非常强大,但实际上Cordova的生态系统更加成熟和一致。 Maybe you should take a look at NativeScript . 也许你应该看看NativeScript

Is react native web view as powerful as Cordova? 是否将本地Web视图与Cordova一样强大?

Answer: It's more powerful than Cordova 答:它比Cordova更强大

Unlike Cordova/PhoneGap your code runs in a JS runtime on the OS, but the UI is rendered as native components. 与Cordova / PhoneGap不同,您的代码在操作系统上的JS运行时中运行,但UI呈现为本机组件。 This makes it very different than Cordova/PhoneGap. 这使它与Cordova / PhoneGap非常不同。 You can use the standard platform components such as UITabBar on iOS and Drawer on Android. 您可以使用标准平台组件,例如iOS上的UITabBar和Android上的Drawer。 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. 这些组件可以使用他们的React组件对应物轻松整合到您的应用程序中,例如TabBarIOS和DrawerLayoutAndroid。

As for Cordova, you're bound to the limitations of the WebView.And since JavaScript is single threaded, you will at one point run into issues if there are too many things going on in your application code. 至于Cordova,你必然受到WebView的限制。而且由于JavaScript是单线程的,如果你的应用程序代码中发生的事情太多,你将会遇到问题。 Such as sluggish animations etc... 比如迟钝的动画等......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM