{"id":29921,"date":"2024-11-25T17:44:34","date_gmt":"2024-11-25T09:44:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29921\/"},"modified":"2024-11-25T17:44:34","modified_gmt":"2024-11-25T09:44:34","slug":"%e4%bd%bf%e7%94%a8hprose%e5%bc%80%e5%8f%91%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e7%9a%84%e5%ae%9e%e4%be%8b%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29921\/","title":{"rendered":"\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u89e3\u6790"},"content":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff1f\u4e0b\u9762\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e0b\uff1a<\/p>\n<p style=\"margin: 25px 0px;padding: 10px 0px 10px 10px;border-width: 0px 0px 0px 5px;border-top-style: initial;border-right-style: initial;border-bottom-style: initial;border-left-style: solid;border-top-color: initial;border-right-color: initial;border-bottom-color: initial;vertical-align: baseline;font-size: 18px;line-height: 20px;font-family:\">1.\u4e0b\u8f7d\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5de5\u5177\uff0c\u5b89\u88c5<\/p>\n<p>\u5982\u679c\u5df2\u7ecf\u5177\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5de5\u5177\u5c31\u4e0d\u7528\u4e0b\u8f7d\u4e86\uff0c\u5f00\u53d1\u5de5\u5177\u4e0b\u8f7d\uff1amp.weixin.qq.com\/debug\/wxadoc\/dev\/devtools\/devtools.html?t=1474644083132<\/p>\n<p style=\"margin: 25px 0px;padding: 10px 0px 10px 10px;border-width: 0px 0px 0px 5px;border-top-style: initial;border-right-style: initial;border-bottom-style: initial;border-left-style: solid;border-top-color: initial;border-right-color: initial;border-bottom-color: initial;vertical-align: baseline;font-size: 18px;line-height: 20px;font-family:\">2.\u4e0b\u8f7dhprose-html5 \u6216\u8005 hprose-js<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a&nbsp;hprose-html5&nbsp;\u6216\u8005&nbsp;hprose-js\u3002<br \/>\u63a8\u8350\u4f7f\u7528&nbsp;hprose-html5&nbsp;\u7248\u672c\uff0c\u8fd9\u4e2a\u7248\u672c\u66f4\u5c0f\uff0c\u652f\u6301\u4e8c\u8fdb\u5236\u6570\u636e\u4f20\u8f93\uff0c\u800c\u4e14\u66f4\u5feb\u3002<\/p>\n<p>\u53ef\u4ee5\u7528&nbsp;git clone&nbsp;\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u53ea\u4e0b\u8f7d&nbsp;dist&nbsp;\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c<\/p>\n<p style=\"margin: 25px 0px;padding: 10px 0px 10px 10px;border-width: 0px 0px 0px 5px;border-top-style: initial;border-right-style: initial;border-bottom-style: initial;border-left-style: solid;border-top-color: initial;border-right-color: initial;border-bottom-color: initial;vertical-align: baseline;font-size: 15px;line-height: 20px;font-family:\">3.\u4ee5&nbsp;hprose-html5&nbsp;\u7248\u672c\u4e3a\u4f8b\uff1a<\/p>\n<p>hprose-html5.src.js&nbsp;\u662f\u6e90\u7801\u7248\u672c&nbsp;hprose-html5.js&nbsp;\u662f\u538b\u7f29\u7248\u672c<\/p>\n<p>\u8fd9\u4e24\u4e2a\u7248\u672c\u90fd\u53ef\u4ee5\u7528\u3002\u8c03\u8bd5\u9636\u6bb5\u5efa\u8bae\u7528\u6e90\u7801\u7248\u672c\u3002\u4f46\u4e0d\u8981\u4f7f\u7528&nbsp;hprose-html5.min.js&nbsp;\u7248\u672c\uff0c\u8fd9\u4e2a\u7248\u672c\u662f\u538b\u7f29\u7248\u672c\u7684\uff0c\u4e0d\u652f\u6301\u5728\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u7f16\u8bd1\u3002<\/p>\n<p>\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u4eec\u590d\u5236\u5230\u4f60\u521b\u5efa\u7684\u90a3\u4e2a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684&nbsp;utils&nbsp;\u76ee\u5f55\u4e0b\uff08\u590d\u5236\u5176\u4e2d\u4e00\u4e2a\u5c31\u53ef\u4ee5\uff09\uff0c\u7136\u540e\u5c06\u5b83\u6539\u540d\u4e3a&nbsp;hprose.js\uff08\u8fd9\u4e00\u6b65\u53ef\u9009\uff0c\u53ea\u4e3a\u540e\u9762\u5f15\u7528\u7684\u65f6\u5019\uff0c\u540d\u79f0\u7edf\u4e00\uff09\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6253\u5f00&nbsp;pages\/index\/index.js&nbsp;\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u5f00\u5934\u52a0\u4e0a\uff1a<\/p>\n<pre>var&nbsp;hprose&nbsp;=&nbsp;require('..\/..\/utils\/hprose.js');<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u5728&nbsp;onLoad&nbsp;\u4e8b\u4ef6\u4e2d\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>var&nbsp;client&nbsp;=&nbsp;hprose.Client.create(\"http:\/\/www.hprose.com\/example\/\",&nbsp;[\"hello\"]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;client.hello(\"world\",&nbsp;function(result)&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;console.log(result);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u603b\u4f53\u770b\u4e0a\u53bb\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre>\/\/index.js&nbsp;\r\nvar&nbsp;hprose&nbsp;=&nbsp;require('..\/..\/utils\/hprose.js');&nbsp;\/\/\u83b7\u53d6\u5e94\u7528\u5b9e\u4f8b\r\nvar&nbsp;app&nbsp;=&nbsp;getApp()&nbsp;Page({&nbsp;&nbsp;&nbsp;\r\ndata:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\nmotto:&nbsp;'Hello&nbsp;World',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\nuserInfo:&nbsp;{}&nbsp;&nbsp;\r\n&nbsp;},&nbsp;&nbsp;\r\n&nbsp;&nbsp;\/\/\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&nbsp;&nbsp;&nbsp;\r\n&nbsp;bindViewTap:&nbsp;function()&nbsp;\r\n&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;wx.navigateTo({&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;url:&nbsp;'..\/logs\/logs'&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp;\r\n&nbsp;},&nbsp;&nbsp;&nbsp;\r\n&nbsp;onLoad:&nbsp;function&nbsp;()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;console.log('onLoad')&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;var&nbsp;client&nbsp;=&nbsp;hprose.Client.create(\"http:\/\/www.hprose.com\/example\/\",&nbsp;[\"hello\"]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;client.hello(\"world\",&nbsp;function(result)&nbsp;\r\n&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;console.log(result);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;that&nbsp;=&nbsp;this&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;\/\/\u8c03\u7528\u5e94\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u83b7\u53d6\u5168\u5c40\u6570\u636e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;app.getUserInfo(function(userInfo){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;\/\/\u66f4\u65b0\u6570\u636e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;that.setData({&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;userInfo:userInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp;\r\n&nbsp;&nbsp;&nbsp;}&nbsp;\r\n&nbsp;&nbsp;&nbsp;})<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u70b9\u7f16\u8bd1\uff0c\u8fd0\u884c\uff0c\u5982\u679c\u4f60\u7684\u7f51\u7edc\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4f60\u4f1a\u5728\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\u770b\u5230\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/672\/382\/460\/1493691953358638.jpg\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u89e3\u6790\u63d2\u56fe\" alt=\"\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u89e3\u6790\u63d2\u56fe\" \/><\/p>\n<p>\u5c31\u8fd9\u4e48\u7b80\u5355\uff0c\u4f60\u53ef\u4ee5\u7528&nbsp;hprose&nbsp;\u6765\u505a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u89e3\u6790\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528hprose\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff1f\u4e0b\u9762\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e0b\uff1a 1.\u4e0b\u8f7d\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5de5\u5177\uff0c\u5b89\u88c5 \u5982\u679c\u5df2\u7ecf\u5177\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5de5\u5177\u5c31\u4e0d\u7528\u4e0b\u8f7d\u4e86\uff0c\u5f00\u53d1\u5de5\u5177\u4e0b\u8f7d\uff1amp.weixin.qq.com\/debug\/wxadoc\/dev\/devtools\/devtools.html?t=1474644083132 2.\u4e0b\u8f7dhprose-html5 \u6216\u8005 hprose-js \u4e0b\u8f7d\u5730\u5740\uff1a&nbsp;hprose-html5&nbsp;\u6216\u8005&nbsp;hprose-js\u3002\u63a8\u8350\u4f7f\u7528&nbsp;hprose-html5&nbsp;\u7248\u672c\uff0c\u8fd9\u4e2a\u7248\u672c\u66f4\u5c0f\uff0c\u652f\u6301\u4e8c\u8fdb\u5236\u6570\u636e\u4f20\u8f93\uff0c\u800c\u4e14\u66f4\u5feb\u3002 \u53ef\u4ee5\u7528&nbsp;git clone&nbsp;\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u53ea\u4e0b\u8f7d&nbsp;dist&nbsp;\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c 3.\u4ee5&nbsp;hprose-html5&nbsp;\u7248\u672c\u4e3a\u4f8b\uff1a hprose-html5.src.js&nbsp;\u662f\u6e90\u7801\u7248\u672c&nbsp;hprose-html5.js&nbsp;\u662f\u538b\u7f29\u7248\u672c \u8fd9\u4e24\u4e2a\u7248\u672c\u90fd\u53ef\u4ee5\u7528\u3002\u8c03\u8bd5\u9636\u6bb5\u5efa\u8bae\u7528\u6e90\u7801\u7248\u672c\u3002\u4f46\u4e0d\u8981\u4f7f\u7528&nbsp;hprose-html5.min.js&nbsp;\u7248\u672c\uff0c\u8fd9\u4e2a\u7248\u672c\u662f\u538b\u7f29\u7248\u672c\u7684\uff0c\u4e0d\u652f\u6301\u5728\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u7f16\u8bd1\u3002 \u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u4eec\u590d\u5236\u5230\u4f60\u521b\u5efa\u7684\u90a3\u4e2a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684&nbsp;utils&nbsp;\u76ee\u5f55\u4e0b\uff08\u590d\u5236\u5176\u4e2d\u4e00\u4e2a\u5c31\u53ef\u4ee5\uff09\uff0c\u7136\u540e\u5c06\u5b83\u6539\u540d\u4e3a&nbsp;hprose.js\uff08\u8fd9\u4e00\u6b65\u53ef\u9009\uff0c\u53ea\u4e3a\u540e\u9762\u5f15\u7528\u7684\u65f6\u5019\uff0c\u540d\u79f0\u7edf\u4e00\uff09\u3002 \u63a5\u4e0b\u6765\uff0c\u6253\u5f00&nbsp;pages\/index\/index.js&nbsp;\u6587\u4ef6\u3002 \u5728\u5f00\u5934\u52a0\u4e0a\uff1a var&nbsp;hprose&nbsp;=&nbsp;require(&#8216;..\/..\/utils\/hprose.js&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u7136\u540e\u5728&nbsp;onLoad&nbsp;\u4e8b\u4ef6\u4e2d\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a var&nbsp;client&nbsp;=&nbsp;hprose.Client.create(&#8220;http:\/\/www.hprose.com\/example\/&#8221;,&nbsp;[&#8220;hello&#8221;]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;client.hello(&#8220;world&#8221;,&nbsp;function(result)&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;console.log(result);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;}); \u767b\u5f55\u540e\u590d\u5236 \u603b\u4f53\u770b\u4e0a\u53bb\u662f\u8fd9\u6837\u7684\uff1a \/\/index.js&nbsp; var&nbsp;hprose&nbsp;=&nbsp;require(&#8216;..\/..\/utils\/hprose.js&#8217;);&nbsp;\/\/\u83b7\u53d6\u5e94\u7528\u5b9e\u4f8b var&nbsp;app&nbsp;=&nbsp;getApp()&nbsp;Page({&nbsp;&nbsp;&nbsp; data:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; motto:&nbsp;&#8216;Hello&nbsp;World&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userInfo:&nbsp;{}&nbsp;&nbsp; &nbsp;},&nbsp;&nbsp; &nbsp;&nbsp;\/\/\u4e8b\u4ef6\u5904\u7406\u51fd\u6570&nbsp;&nbsp;&nbsp; &nbsp;bindViewTap:&nbsp;function()&nbsp; &nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;wx.navigateTo({&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;url:&nbsp;&#8216;..\/logs\/logs&#8217;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp; &nbsp;},&nbsp;&nbsp;&nbsp; &nbsp;onLoad:&nbsp;function&nbsp;()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;console.log(&#8216;onLoad&#8217;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;var&nbsp;client&nbsp;=&nbsp;hprose.Client.create(&#8220;http:\/\/www.hprose.com\/example\/&#8221;,&nbsp;[&#8220;hello&#8221;]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;client.hello(&#8220;world&#8221;,&nbsp;function(result)&nbsp; &nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;console.log(result);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;that&nbsp;=&nbsp;this&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;\/\/\u8c03\u7528\u5e94\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u83b7\u53d6\u5168\u5c40\u6570\u636e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;app.getUserInfo(function(userInfo){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;\/\/\u66f4\u65b0\u6570\u636e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;that.setData({&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;userInfo:userInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;})&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}&nbsp; &nbsp;&nbsp;&nbsp;}) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-29921","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29921"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29921\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}