我想在 React Native 的脚本中导入模块。该模块只有 index.android.js
,因此在 iOS 上导入会失败。
既然我在 iOS 中不需要该模块,我怎样才能忽略它呢?
我尝试使用 if (Platform.OS == 'android') Module = require('module')
但它仍然抛出 UnableToResolveError:
Module does not exist in the module map or in these directories: D:\myproject\node_modules
重要: 我不想修改模块。
最佳答案
你可以尝试利用这个https://github.com/facebook/react-native/issues/7271这不是完整的答案,但可以帮助您。
关于javascript - 如何忽略 React Native 中的导入失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50836012/