我在我的本机项目中集成了Realm,当我使用realm文档中定义的import语句时出现错误。
const Realm = require('realm');
我已按照网络上的所有步骤操作,但仍然收到错误消息。这是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')
答案 0 :(得分:1)
仅供参考:我可以在导入领域之前添加这些行来解决问题。
if (typeof global.self === 'undefined') {
global.self = global;
}
我在这里找到了可能的解决方法:https://github.com/facebook/react-native/issues/9599