9***@qq.com
9***@qq.com
  • 发布:2020-02-17 10:04
  • 更新:2020-04-01 13:30
  • 阅读:3177

uniapp使用protobuf引入出现问题,h5使用没问题,真机调试出现问题

分类:uni-app

报错原因,引入protobuf编译的js

import Message from '../../protobuf/ChatMessage_pb.js'

报错内容
09:52:02.504 reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Exception: ReferenceError: Can't find variable: self
09:52:02.549 eval code
09:52:02.574 eval@[native code]
09:52:02.595 weex createInstanceContext:436:5
09:52:02.620 webpack_require@weex createInstanceContext:79:34
09:52:02.641 eval code
09:52:02.662 eval@[native code]
09:52:02.683 weex createInstanceContext:425:5
09:52:02.704
webpack_require
@weex createInstanceContext:79:34
09:52:02.746 eval code
09:52:02.770 eval@[native code]
09:52:02.792 weex createInstanceContext:403:5
09:52:02.813 webpack_require@weex createInstanceContext:79:34
09:52:02.836 eval code
09:52:02.857 eval@[native code]
09:52:02.878 weex createInstanceContext:163:5
09:52:02.899
webpack_require
@weex createInstanceContext:79:34
09:52:02.920 checkDeferredModules@weex createInstanceContext:46:42
09:52:02.941 webpackJsonpCallback@weex createInstanceContext:33:39
09:52:02.962 global code@weex createInstanceContext:154:57
09:52:03.004 getTemplateInfo== template md5 1d9e40b411685a7342231bfcce0c5295 length 1612937 base64 md5 HZ5AtBFoWnNCIxv8zgxSlQ== response header {"templateSourceBase64MD5":["HZ5AtBFoWnNCIxv8zgxSlQ=="],"templateSourceMD5":["1d9e40b411685a7342231bfcce0c5295"]}

2020-02-17 10:04 负责人:无 分享
已邀请:
[已删除]

[已删除]

老哥解决没有,遇到同样的问题

[已删除]

[已删除]

我暂时修改了 google-protobuf.js 的代码。可以引入使用了。暂时也没有发现报错 。
在 node_modules/google-protobuf/google-protobuf 搜索self 只有一个 然后我将它替换成了goog.
小白不知道会不会引发未知的问题,至少现在能用了。
坐等大佬指点迷津

该问题目前已经被锁定, 无法添加新回复