我在react原生项目中集成Realm时,在使用realm文档中定义的import语句时出现错误。
const Realm = require('realm');我已经遵循了web上的所有步骤,但仍然收到错误。这是Xcode的输出错误:
2018-05-31 11:11:53.037 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.036887+0200 wallet-development[1734:651340] Unhandled JS Exception: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.040 [warn][tid:com.facebook.react.JavaScript] Unable to symbolicate stack trace: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')
2018-05-31 11:11:53.040236+0200 wallet-development[1734:651343] Unable to symbolicate stack trace: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')这是我在电话里听到的:

发布于 2018-05-31 23:29:42
仅供参考:我可以通过在导入领域之前添加这些行来解决这个问题。
if (typeof global.self === 'undefined') {
global.self = global;
}我在这里找到了可能的修复方法:https://github.com/facebook/react-native/issues/9599
https://stackoverflow.com/questions/50620923
复制相似问题