Egret之ProtoBuf(引用)
一 : test.proto(在protobuf\protofile中)
package Test;message LVO{ required string message = 1; required int32 priority = 2;}message Login{ required string userName = 1; required string password = 2; optional int32 sex = 3; required LVO lvo = 4; required bool isFirstLogin = 5; repeated string param = 6;}
① , Login引用了LVO
二 : 使用命令pb-egret generate① , 必须注意的是 : proto文件在protobuf\protofile中,这样使用pb-egret generate后,会生成文件在protobuf\bundles中 :
② , 我们可以看看生成的相关的.d.ts(protobuf-bundles.d.ts)
let $login : Test.ILogin = new Test.Login({ userName:"Aonaufly", password:"123456", sex:1, lvo:{ message : "Snow", priority : 1 }, isFirstLogin:false, param:["test", "array", "param"] });
① , 使用Login中的lvo数据 $login.lvo.message
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。