ios - 如何制作需要特定导入的混合包 React/React-Native
<p><p>是否可以为需要特定导入的 React 和 React-Native 创建一个混合包,例如使用 React-Native 我必须导入 AsyncStorage,但对于 React(使用 localStorage)我不需要这个。 </p>
<p>所以我想知道使用条件检测应用程序是否为 React-Native 来处理这两种情况是否可行。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>为了检测应用程序是否为 React-Native,您需要使用平台特定的逻辑。根据 <a href="https://github.com/facebook/react-native/commit/3c65e62183ce05893be0822da217cb803b121c61" rel="noreferrer noopener nofollow">this commit</a> ,您应该可以通过以下方式进行检查:</p>
<p><code>navigator.product === 'ReactNative'</code></p>
<p>另请参见此处了解特定平台:
<a href="https://facebook.github.io/react-native/docs/platform-specific-code.html" rel="noreferrer noopener nofollow">https://facebook.github.io/react-native/docs/platform-specific-code.html</a> </p></p>
<p style="font-size: 20px;">关于ios - 如何制作需要特定导入的混合包 React/React-Native,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41404692/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41404692/
</a>
</p>
页:
[1]