使用protobuf.js 6.11.x时,由于环境禁止使用eval等安全函数,导致不能使用load加载proto文件。虽然文档里有说可以使用静态代码生成的方式,但由于proto文件太多,导致生成的静态代码过于庞大,还是想使用load加载proto文件的方式,如何才能解决
page: pages/Index.js
Error message: Not support eval. Forbidden using new Function()/Function().
SourceCode:
return Function(source)(); // eslint-disable-line no-new-func
^
Stacktrace:
at Codegen (entry/oh_modules/.ohpm/@protobufjs+codegen@2.0.4/oh_modules/@protobufjs/codegen/index.js:51:14)
at get (entry/oh_modules/.ohpm/protobufjs@6.11.3/oh_modules/protobufjs/src/type.js:145:41)
at resolve (entry/oh_modules/.ohpm/protobufjs@6.11.3/oh_modules/protobufjs/src/field.js:281:7)
at encoder (entry/oh_modules/.ohpm/protobufjs@6.11.3/oh_modules/protobufjs/src/encoder.js:34:17)
at setup (entry/oh_modules/.ohpm/protobufjs@6.11.3/oh_modules/protobufjs/src/type.js:380:17)
at verify_setup (entry/oh_modules/.ohpm/protobufjs@6.11.3/oh_modules/protobufjs/src/type.js:47
协议缓冲区提供了一种语言中立、平台中立、可扩展的机制,用于以向前兼容和向后兼容的方式序列化结构化数据。它类似于 JSON,只是它更小更快,并且生成本地语言绑定