React Native 应用程序(意味着相同的代码库)可以变成移动网络应用程序吗? [英] Can React Native app (means same codebase) be turned into mobile web app?
问题描述
是否可以在移动网络和移动应用之间共享相同的 REACT 代码库?
很遗憾,您不能.React Native 使用了一堆预先构建的组件,这些组件实际上只是封装在 Javascript 中的原生 iOS 组件.例如,你可以在 React 中使用
但在 React Native 中你必须使用
code>,图片只能在
组件中显示,等等.对于每个React Native组件可以拥有的样式、数据或嵌套组件也有更严格的限制.顺便说一句,尝试这样做有悖于 React 的理念 -> '学习一次,随处编写'.如果您对可以轻松移植到移动应用程序的内容感兴趣,可以尝试查看 Ionic.
Whether the same REACT codebase can be shared across mobile web and mobile app?
Unfortunately, you cannot. React Native uses a bunch of pre-built components that are really just native iOS components wrapped in Javascript. For example, you could use <div>
or <span>
in React but in React Native you'd have to use <Text>
, images can only be displayed in <Image>
components, etc. There are also stricter limitations on what styles, data, or nested components each React Native component can have.
On a side note, trying to do this goes against the React philosphy -> 'Learn once, write anywhere'. You can try taking a look at Ionic if you're interested in something that ports easily over to mobile apps.
这篇关于React Native 应用程序(意味着相同的代码库)可以变成移动网络应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!