Closed DokiDoki1103 closed 1 year ago
服务器返回了arraybuffer数据,怎么使用protojs文件解析呢?
You are correct that deserializeBinary
is a static method. Can you convert the ArrayBuffer to a Uint8Array?
我认为 deserializeBinary 方法应该定义为类的方法 如同这样 proto.LoginResponse.prototype.deserializeBinary 然后const msg = new Message()然后调用 meg.deserializeBinary() 直接反序列化为msg对象,直接调用getXx取值
We believe deserializeBinary
is naturally a static method. The semantics are oriented around constructing a message from a data blob rather than populating an existing message. We have no plans to change this.
由于反序列化的方法中没有prototype故无法通过官网那样new出来的对象调用deserializeBinary方法。
只能 import messages from "../proto/sso_pb" 后 messages.LoginResponse.deserializeBinary(res.data)
而不是像官网一样new