【问题标题】:How to ignore an import fail in React Native?如何在 React Native 中忽略导入失败?
【发布时间】:2018-06-13 11:24:10
【问题描述】:

我想在 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

重要: 我不想修改模块。

【问题讨论】:

    标签: javascript android node.js react-native import


    【解决方案1】:

    您可以尝试使用此https://github.com/facebook/react-native/issues/7271 这不是一个完整的答案,但它可以帮助您。

    【讨论】:

      猜你喜欢
      • 2016-05-09
      • 2019-11-17
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 2021-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多