Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

后台是用protobuf写的,作为前端的我怎么与其进行数据交互?

现在真是一筹莫展,又不懂protobuf。有么有大牛懂套路的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

步骤如下:

  1. 问后端要数据模型文件,比如名为 MODEL.proto;

  2. 使用谷歌官方的工具生成 MODEL.js;

  3. 在项目中引用MODEL.js 和谷歌官方的Javascript runtime支持的库文件;

  4. 把二进制的ArrayBuffer数据反序列化,MODEL.deserializeBinary(BINARY_DATA);

具体的细节,去看谷歌官方的项目和文档。protobuf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...