{"id":29969,"date":"2024-11-25T12:02:40","date_gmt":"2024-11-25T04:02:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29969\/"},"modified":"2024-11-25T12:02:40","modified_gmt":"2024-11-25T04:02:40","slug":"%e6%80%9d%e8%80%83%e5%85%b3%e4%ba%8e%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e7%9a%84%e5%bc%80%e5%8f%91%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29969\/","title":{"rendered":"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b"},"content":{"rendered":"<p>\u82e5\u65e0\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u7ecf\u9a8c\uff0c\u53ef\u5148\u9605\u8bfb&nbsp;\u73a9\u8f6c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f&nbsp;\u4e00\u6587\u3002<\/p>\n<p>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6b63\u5f0f\u4e0a\u7ebf\u5df2\u6709\u51e0\u5468\u65f6\u95f4\uff0c\u76f8\u4fe1\u5b83\u7684\u5f00\u53d1\u6a21\u5f0f\u4f60\u5df2\u70c2\u719f\u4e8e\u80f8\uff0c\u53ef\u80fd\u4f60\u4e5f\u6709\u6240\u7591\u95ee\uff0c\u6211\u7adf\u80fd\u7528 web \u8bed\u8a00\u5f00\u53d1\u51fa\u5982\u6b64\u6d41\u7545\u7684\u51e0\u4e4e\u539f\u751f\u4f53\u9a8c\u7684\u5e94\u7528\u3002\u53ef\u80fd\u4f60\u53c8\u4f1a\u731c\u8fd9\u4e0d\u5c31\u662f h5 \u4e48\uff0c\u5389\u5bb3\u70b9\u7684\u60f3\u4e0d\u5c31\u662f hybrid \u4e48\u3002\u4f46\u662f\u5728\u6211\u4eec\u7684\u5f00\u53d1\u65c5\u9014\u4e2d\u81f3\u59cb\u81f3\u7ec8\u90fd\u6ca1\u6709\u4f7f\u7528\u8fc7 webview \uff0c\u4e3a\u5565\u5462\uff1f\u5f00\u53d1\u65f6\u7528\u7684 view \u4e00\u7c7b\u7684\u6807\u7b7e\uff0c\u6d4f\u89c8\u5668\u53c8\u662f\u600e\u4e48\u89e3\u6790\u6210\u9875\u9762\u7684\u5462\uff1f\u5e26\u7740\u91cd\u91cd\u7591\u60d1\uff0c\u8fdb\u5165\u5fae\u4fe1\u5206\u6790\u5427\uff01<\/p>\n<h4>\u5f00\u53d1\u5e73\u53f0<\/h4>\n<p>\u8fd9\u4e2a IDE \u662f\u5982\u4f55\u4fdd\u8bc1\u6211\u4eec\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u9884\u89c8\u7684\uff1f\u7b80\u8981\u5206\u6790\u4e24\u70b9\u3002<\/p>\n<p>1. \u6587\u4ef6\u76ee\u5f55<\/p>\n<p>\u6253\u5f00&nbsp;\u76ee\u5f55&nbsp;\uff0c\u8fdb\u5165&nbsp;package.nw&nbsp;\uff0c\u55ef\uff1f\u719f\u6089\u7684\u5473\u9053\u6765\u4e86\u3002\u91cc\u9762\u5c313\u4e2a\u6587\u4ef6\uff1aapp&nbsp;\uff0cnode_modules\uff0cpackage.json&nbsp;\u3002\u663e\u7136\u6211\u4eec\u5f00\u53d1\u65f6\u6784\u5efa\u9636\u6bb5\u6240\u7528\u8d44\u6e90\u6765\u81ea\u4e8e node_modules \uff0c\u4e8e\u662f\u6211\u5c1d\u8bd5\u627e\u4e0b&nbsp;react\u6a21\u5757\uff0c\u7ed3\u679c\u6ca1\u6709\u6536\u83b7&#8230;<\/p>\n<p>\u8fdb\u5165 app \u76ee\u5f55\u4e0b\uff0c\u5448\u73b0\u7684\u56db\u4e2a\u6587\u4ef6\u5939\u5206\u522b\u662f\uff1ahtml&nbsp;\uff0cstyle&nbsp;\uff0cimages&nbsp;\uff0cdist&nbsp;\u3002\u800c\u4f60\u5f00\u53d1\u65f6\u4f7f\u7528\u7684 IDE \u7684\u5b9e\u73b0\u6b63\u662f\u901a\u8fc7\u8fd9\u4e9b\u6587\u4ef6\uff0c\u4e0d\u59a8\u7528\u6d4f\u89c8\u5668\u6253\u5f00\u5176\u4e2d\u4e00\u4e2a html \u770b\u770b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/0f00638732771922cb894336b4206c0c-0.png\" class=\"aligncenter\" title=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe\" alt=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe\" \/><\/p>\n<p>\u8fd9\u4e0d\u5c31\u662f\u4ece\u684c\u9762\u6253\u5f00\u540e\u770b\u5230\u7684\u6548\u679c\u5417\uff08\u5176\u4e2d&nbsp;nodeWebkit&nbsp;\u63d0\u4f9b\u4e86 web \u5230\u684c\u9762\u5e94\u7528\u7684\u8f6c\u6362\uff09\u3002\u5e76\u4e14\u5728&nbsp;index.html&nbsp;\u4e2d\u627e\u5230\u6211\u4eec\u7684\u4e3b\u811a\u672c\u6587\u4ef6&nbsp;..\/dist\/app.js&nbsp;\uff0c\u6574\u4e2a IDE \u4ece\u7f16\u8f91\uff0c\u5f00\u53d1\uff0c\u9884\u89c8\uff0c\u53d1\u5e03\u7b49\u4e00\u7cfb\u5217\u64cd\u4f5c\u90fd\u5728 app.js \u53ca\u5176\u7684\u811a\u672c\u4e2d\u3002<\/p>\n<p>2. \u903b\u8f91\u5173\u7cfb<\/p>\n<p>\u63a5\u4e0b\u6765\u5f00\u59cb\u5206\u6790\u4e0b&nbsp;dist&nbsp;\u4e0b\u6709\u4ec0\u4e48\u9b3c\u3002 \u4e0d\u8981\u6015\uff0c\u4e5f\u5c31\u51e0\u5341\u884c\u7684\u6e90\u7801\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/f54c67bd63eb558ff32b1bbab01fad48-1.png\" class=\"aligncenter\" title=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe1\" alt=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe1\" \/><\/p>\n<p>\u4e0d\u8fc7\u6bcf\u884c\u90fd\u662f\u538b\u7f29\u8fc7\u540e\u7684\u800c\u5df2&#8230;\u597d\u5427\uff0c\u4e22\u53bb\u53cd\u538b\u7f29\u4e00\u4e0b\u3002\u5728 Sublime Text3 \u4e2d\u88c5\u4e00\u4e2a&nbsp;jsmat&nbsp;\u7684\u63d2\u4ef6\uff0c\u5bf9\u8981\u683c\u5f0f\u5316\u7684\u4ee3\u7801\u8fdb\u884c Ctrl + Alt + F \u5373\u53ef\uff0c\u63a5\u4e0b\u6765\u5bf9\u6211\u4eec\u7684\u6587\u4ef6\u8fdb\u884c\u4e00\u4e2a\u903b\u8f91\u5212\u5206\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/f54c67bd63eb558ff32b1bbab01fad48-2.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe2\" alt=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe2\" \/><\/p>\n<p>\u663e\u7136\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f IDE \u672c\u8eab\u662f\u7528 React \u7ec4\u4ef6\u5e76\u4e14\u4ee5 Flux \u7684\u6765\u6784\u5efa\u7684\uff0c\u90a3\u6211\u4eec\u6240\u7f16\u5199\u7684\u5c0f\u7a0b\u5e8f\u53c8\u662f\u5982\u4f55\u8fd0\u884c\u8d77\u6765\u7684\u5462\uff1f\u9996\u5148\u4ece .\/app\/dist\/components\/sidebar\/sidebar.js \u5f00\u59cb\u770b\u8d77\uff0c\u627e\u5230 React Render \u51fa\u7684&nbsp;restart&nbsp;(\u7f16\u8bd1\u6309\u94ae\u7684\u4e0a\u65b9)\u3002<\/p>\n<pre>\/\/&nbsp;sidebar.jsa.createElement('p',&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;className:&nbsp;'sidebar-item&nbsp;sidebar-item-sep'\r\n}),&nbsp;a.createElement('p',&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;className:&nbsp;'sidebar-item-toolbar',&nbsp;&nbsp;&nbsp;&nbsp;style:&nbsp;p\r\n},&nbsp;a.createElement(g,&nbsp;null),&nbsp;a.createElement('p',&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;title:&nbsp;`${'darwin'===process.platform?'Command':'Ctrl'}&nbsp;+&nbsp;b`,&nbsp;&nbsp;&nbsp;&nbsp;onClick:&nbsp;this.handleAppRestart,&nbsp;&nbsp;&nbsp;&nbsp;className:&nbsp;'sidebar-item',&nbsp;&nbsp;&nbsp;&nbsp;style:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;paddingBottom:&nbsp;0\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n},&nbsp;a.createElement('i',&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;className:&nbsp;'sidebar-item-icon&nbsp;&nbsp;sidebar-item-icon-reset'\r\n}));<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6bcf\u5f53\u70b9\u51fb\u8fd9\u4e2a\u6309\u94ae\u65f6\uff0cIDE \u90fd\u4f1a\u91cd\u65b0\u5c55\u73b0\u5f53\u524d app \u3002\u6240\u4ee5\u8fd9\u4e2a&nbsp;handleAppRestart&nbsp;\u5c31\u662f\u5173\u952e\u4e4b\u5904\u4e86\u3002<\/p>\n<h4>\u9875\u9762\u6784\u5efa<\/h4>\n<p>1. \u6784\u5efa\u6d41\u7a0b<\/p>\n<p>\u89e6\u53d1 handleAppRestart \u7684 200ms \u540e\u4f1a\u8c03\u7528&nbsp;.\/actions\/projectActions.js&nbsp;\u4e2d\u7684&nbsp;restart&nbsp;\u65b9\u6cd5\uff0c\u6784\u5efa\u6d41\u7a0b\u6b63\u5f0f\u5f00\u59cb\u3002<\/p>\n<pre>\/\/&nbsp;sidebar.js\r\nhandleAppRestart:&nbsp;function(l)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;clearTimeout(j),&nbsp;j&nbsp;=&nbsp;setTimeout(()&nbsp;=&amp;gt;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.restart(this.props.project);&nbsp;\/\/&nbsp;e\u4e3aprojectActions.js\u8f93\u51fa\u5bf9\u8c61&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;m&nbsp;=&nbsp;'edit'&nbsp;===&nbsp;this.props.show&nbsp;?&nbsp;`project_compile`&nbsp;:&nbsp;`project_restart`;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i(m,&nbsp;this.props.project.appid)\r\n&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;200)\r\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 projectActions.js \u4e2d\uff0c\u53ef\u4ee5\u6e05\u695a\u7684\u770b\u5230 flux \u67b6\u6784\u7684\u90e8\u5206 actions \uff0c\u8fd9\u4e9b&nbsp;actions&nbsp;\u90fd\u4f1a\u968f\u7740&nbsp;dispatch&nbsp;\u4f20\u5165\u5230&nbsp;store&nbsp;\u5f53\u4e2d\uff0c\u8fdb\u884c\u4e00\u4e2a\u7684\u6539\u53d8\uff0c\u6700\u540e\u91cd\u65b0\u6e32\u67d3\u5230\u5e94\u7528\u4e2d\u3002<\/p>\n<pre>\/\/&nbsp;projectActions.jsdel:&nbsp;function(b)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;a.dispatch({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;actionType:&nbsp;'DELETE_PROJECT',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;projectid:&nbsp;b\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n},\r\nadd:&nbsp;function(b,&nbsp;c)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;a.dispatch({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;actionType:&nbsp;'ADD_PROJECT',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;project:&nbsp;b,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;needInitQuickStart:&nbsp;c\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n},\r\nclose:&nbsp;function(b)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;a.dispatch({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;actionType:&nbsp;'CLOSE_PROJECT'\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n},\r\nrestart:&nbsp;function(b)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;a.dispatch({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;actionType:&nbsp;'RESTART_PROJECT',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;project:&nbsp;b\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>projectActions.js \u7684\u6bcf\u4e00\u4e2a action \u90fd\u4f1a\u901a\u8fc7 projectDispatcher.js \u6620\u5c04\u5230&nbsp;projectStores.js&nbsp;\u4e2d\uff0c\u5e94\u7528\u7684&nbsp;restart&nbsp;\uff0cadd\u65b9\u6cd5\u5728 store \u4e2d\u4e5f\u6709\u5177\u4f53\u5b9e\u73b0\u3002<\/p>\n<pre>add:&nbsp;function(F,&nbsp;G)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;F.hash&nbsp;=&nbsp;a(F.projectid),&nbsp;F.es6&nbsp;=&nbsp;!0,&nbsp;F.watcher&nbsp;=&nbsp;!0,&nbsp;F.editWebview&nbsp;=&nbsp;!0,&nbsp;F.newFeature&nbsp;=&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time:&nbsp;Date.now(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;show:&nbsp;!1,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;check:&nbsp;!1\r\n&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;F.initPath&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enable:&nbsp;!1\r\n&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;F.uploadPath&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enable:&nbsp;!1\r\n&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;w.unshift(F),&nbsp;c(F,&nbsp;G),&nbsp;b(),&nbsp;h.info(`projectStores.js&nbsp;add&nbsp;${JSON.stringify(F)}`),&nbsp;this.emit('ADD_PROJECT',&nbsp;w)\r\n},\r\nclose:&nbsp;function()&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;this.emit('CLOSE_PROJECT')\r\n},\r\nrestart:&nbsp;function(F)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;this.emit('RESTART_PROJECT',&nbsp;F)\r\n},<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5bf9\u4e8e Flux\uff0c\u5982\u679c\u8fd8\u4e0d\u6e05\u695a\uff0c\u8fd9\u5f20\u56fe\u53ef\u4ee5\u505a\u4e2a\u7b80\u5355\u7684\u8be0\u91ca\u3002nw \u4e2d\u7528\u7684\u662f facebook \u5b98\u65b9\u7ed9\u51fa\u7684 Flux \u67b6\u6784\uff0chub \u4e0a\u6bd4\u8f83\u6d3b\u8dc3\u7684&nbsp;redux&nbsp;\u548c&nbsp;mobx&nbsp;\u90fd\u662f\u6bd4\u8f83\u597d\u7528\u7684\u72b6\u6001\u7ba1\u7406\u67b6\u6784\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/fda3ce2e8a6104e639b54637695c2cd4-3.png\" class=\"aligncenter\" title=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe3\" alt=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe3\" \/><\/p>\n<p>2. \u4e09\u7aef\u8fd0\u884c<\/p>\n<p>\u5728\u672a android\/ios sdk \u65f6\uff0c\u6211\u4eec\u7684 app \u4f9d\u7136\u80fd\u591f\u5448\u73b0\u5728 IDE \u4e2d\uff0c\u6b64\u65f6\u662f\u901a\u8fc7\u4e91\u7aef\u7684 webpack \u5c06 .wxml\uff0c.wxss\uff0c.js \u8f6c\u6362\u6210 nw \u53ef\u89e3\u6790\u7684 html\uff0ccss\uff0cjs \u3002\u5f53\u7136\u5728 android\/ios \u7684\u5fae\u4fe1\u5ba2\u6237\u7aef\u4e0a\uff0c\u4f9d\u7136\u53ef\u4ee5\u8bbf\u95ee\uff0c\u8fd9\u4fbf\u662f&nbsp;Write Once, run anywhere&nbsp;\uff0c\u6240\u4ee5\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u548c\u963f\u91cc weex \u662f\u5f02\u66f2\u540c\u5de5\u7684\uff0c\u53ea\u4e0d\u8fc7\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684 API \u90fd\u662f\u57fa\u4e8e\u5fae\u4fe1\u7684\u3002<\/p>\n<p>\u4ee5 IOS \u4e3a\u4f8b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/001\/505\/fda3ce2e8a6104e639b54637695c2cd4-4.png\" class=\"aligncenter\" title=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe4\" alt=\"\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u63d2\u56fe4\" \/><\/p>\n<p>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e0e\u4f20\u7edf hybrid \u4f7f\u7528&nbsp;webview&nbsp;\u4e0d\u540c\uff0c\u540e\u8005\u662f\u63d0\u4f9b\u4e86 stringByEvaluatingJavaScriptFromString \u65b9\u6cd5\u8ba9 js \u80fd\u5728\u5f53\u524d context \u4e0a\u6267\u884c\uff0c\u5b9e\u8d28\u4e0a\u8fd8\u662f web \u5e94\u7528\u3002\u800c\u524d\u8005\u662f\u901a\u8fc7 JsBrigde \u5b9a\u4e49\u6a21\u5757\u7684\u65b9\u6cd5\u6620\u5c04\u5230 OcBrigde \u4e2d\uff0c\u8c03\u7528&nbsp;native module&nbsp;\uff0c\u5176\u4e2d\u8fd8\u6709\u5f88\u591a\u56de\u8c03\uff0c\u4f46\u5176\u5b9e\u8d28\u4e0a\u662f native \u5e94\u7528\u3002<\/p>\n<h4>native\u5316<\/h4>\n<p>\u5728\u4f60\u5de5\u4f5c\u6216\u8005\u5b9e\u4e60\u516c\u53f8\u7684\u524d\u7aef\u7ec4\uff0c\u53ef\u80fd\u5df2\u7ecf\u51fa\u73b0\u4e86 native \u5316\u8fd9\u4e9b\u76ee\u6807\uff0c\u8fd9\u7ed9\u516c\u53f8\u5ba2\u6237\u7aef\u4eba\u5458\u5e26\u6765\u4e86\u4e0d\u5c0f\u7684\u5371\u673a\u611f\uff0c\u7684\u786e\uff0c\u524d\u7aef\u80fd\u505a\u7684\u4e8b\u8d8a\u6765\u8d8a\u591a(\u4f9d\u6258\u4e8e\u5f3a\u5927\u7684\u5f00\u6e90\u793e\u533a)\u3002<\/p>\n<p>\u5728\u5408\u9002\u7684\u5e94\u7528\u573a\u666f\u4e0b\uff0c\u6bd4\u5982\u9891\u7387\u4e00\u822c\u6d41\u91cf\u4e0d\u5927\u7684\u4ea7\u54c1\u4e0a\uff0cnative \u5316\u7684\u786e\u662f\u5f88\u597d\u7684\u9009\u62e9\uff0c\u56e0\u4e3a\u5bf9\u4e8e\u4e1a\u52a1\u590d\u6742\u5ea6\u9ad8\u4ee5\u53ca\u4ea7\u54c1\u9700\u8981\u9891\u7e41\u8fed\u4ee3\u7684\u516c\u53f8\u6765\u8bb2\u53ef\u4ee5\u5f88\u5927\u7684\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u4e00\u4e2a\u524d\u7aef\u5de5\u7a0b\u5e08\u80fd\u5b8c\u6210\u66fe\u7ecf\u4e00\u4e2a\u524d\u7aef+\u4e00\u4e2aandroid\u5ba2\u6237\u7aef+\u4e00\u4e2aIOS\u5ba2\u6237\u7aef\u9700\u8981\u5b8c\u6210\u7684\u4efb\u52a1\uff0c\u540c\u65f6\u53c8\u80fd\u907f\u5f00\u591a\u6b21\u53d1\u7248\u7684\u75db\u70b9\uff0c\u6240\u4ee5native \u5316\u5c06\u662f\u524d\u7aef\u672a\u6765\u51e0\u5e74\u4e00\u4e2a\u5fc5\u4fee\u7684\u65b9\u5411\u3002<\/p>\n<p>\u90a3\u5b83\u7a76\u7adf\u5e26\u6765\u4e86\u54ea\u4e9b\u597d\u5904\uff0c\u4e4b\u4e8e web app \uff0c native app \u4ee5\u53ca hybrid app \u53c8\u6709\u54ea\u4e9b\u4f18\u52bf\u5462\uff1f<\/p>\n<p>\u66f4\u4f4e\u7684\u5f00\u53d1\u6210\u672c<\/p>\n<p>Write Once, Run Anywhere&nbsp;\uff0c\u53ea\u8981\u4f60\u4f1a Web \u6280\u672f\uff0c\u540c\u6837\u4e5f\u80fd\u5f00\u53d1\u51fa native \u5e94\u7528\u3002\u8fd9\u5927\u5927\u964d\u4f4e\u4e86\u524d\u7aef\u5f00\u53d1\u8005\u8fdb\u5165\u539f\u751f\u5f00\u53d1\u9886\u57df\u7684\u95e8\u69db\u3002<\/p>\n<p>\u6bd4 hybrid \u66f4\u63a5\u8fd1\u539f\u751f\u7684\u7528\u6237\u4f53\u9a8c<\/p>\n<p>\u89e3\u51b3\u4e86\u4f20\u7edf&nbsp;Webview&nbsp;\u5e26\u6765\u7684\u6027\u80fd\u74f6\u9888\uff0c\u56e0\u4e3a\u8c03\u7528\u7684\u662f\u539f\u751f\u7684\u6a21\u5757\uff0c\u800c\u975e\u76f4\u63a5\u6267\u884c js \u811a\u672c\u3002<\/p>\n<p>\u89e3\u51b3 native \u9891\u7e41\u53d1\u7248\u95ee\u9898<\/p>\n<p>\u5bf9\u4e8e\u654f\u6377\u5f00\u53d1\u7684\u56e2\u961f\u6765\u8bf4\uff0c\u4e3a\u4e86\u80fd\u5feb\u901f\u4e0a\u7ebf\u4ea7\u54c1\uff0c\u4e00\u4e2a\u7248\u672c\u7684\u8fed\u4ee3\u5468\u671f\u53ef\u80fd\u51e0\u5929\u5c31\u884c\u4e86\uff0c\u6240\u4ee5\u53d1\u5e03\u65b0\u7248\u672c\u5c31\u6210\u4e86\u4e00\u4e2a\u65b0\u95ee\u9898\uff0c\u6709\u65f6\u65b0\u7248\u672c\u5b8c\u6210\u5f00\u53d1\uff0c\u800c\u4e0a\u4e00\u4e2a\u7248\u672c\u8fd8\u6ca1\u6709\u5b8c\u6210\u3002\u800c\u5bf9\u4e8e\u7528\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\/ weex \/ React Native \u5f00\u53d1\u7684 app \u53ea\u9700\u8981\u52a0\u8f7d jsbundle \u5373\u53ef\uff0c\u8fd9\u4e2a\u6587\u4ef6\u662f\u53ef\u4ee5\u968f\u65f6\u66f4\u65b0\uff0c\u4ece\u800c app \u5c31\u53ef\u4ee5\u907f\u514d\u91cd\u65b0\u53d1\u5e03\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u601d\u8003\u5173\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\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>\u82e5\u65e0\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u7ecf\u9a8c\uff0c\u53ef\u5148\u9605\u8bfb&nbsp;\u73a9\u8f6c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f&nbsp;\u4e00\u6587\u3002 \u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6b63\u5f0f\u4e0a\u7ebf\u5df2\u6709\u51e0\u5468\u65f6\u95f4\uff0c\u76f8\u4fe1\u5b83\u7684\u5f00\u53d1\u6a21\u5f0f\u4f60\u5df2\u70c2\u719f\u4e8e\u80f8\uff0c\u53ef\u80fd\u4f60\u4e5f\u6709\u6240\u7591\u95ee\uff0c\u6211\u7adf\u80fd\u7528 web \u8bed\u8a00\u5f00\u53d1\u51fa\u5982\u6b64\u6d41\u7545\u7684\u51e0\u4e4e\u539f\u751f\u4f53\u9a8c\u7684\u5e94\u7528\u3002\u53ef\u80fd\u4f60\u53c8\u4f1a\u731c\u8fd9\u4e0d\u5c31\u662f h5 \u4e48\uff0c\u5389\u5bb3\u70b9\u7684\u60f3\u4e0d\u5c31\u662f hybrid \u4e48\u3002\u4f46\u662f\u5728\u6211\u4eec\u7684\u5f00\u53d1\u65c5\u9014\u4e2d\u81f3\u59cb\u81f3\u7ec8\u90fd\u6ca1\u6709\u4f7f\u7528\u8fc7 webview \uff0c\u4e3a\u5565\u5462\uff1f\u5f00\u53d1\u65f6\u7528\u7684 view \u4e00\u7c7b\u7684\u6807\u7b7e\uff0c\u6d4f\u89c8\u5668\u53c8\u662f\u600e\u4e48\u89e3\u6790\u6210\u9875\u9762\u7684\u5462\uff1f\u5e26\u7740\u91cd\u91cd\u7591\u60d1\uff0c\u8fdb\u5165\u5fae\u4fe1\u5206\u6790\u5427\uff01 \u5f00\u53d1\u5e73\u53f0 \u8fd9\u4e2a IDE \u662f\u5982\u4f55\u4fdd\u8bc1\u6211\u4eec\u5c0f\u7a0b\u5e8f\u7684\u5f00\u53d1\u548c\u9884\u89c8\u7684\uff1f\u7b80\u8981\u5206\u6790\u4e24\u70b9\u3002 1. \u6587\u4ef6\u76ee\u5f55 \u6253\u5f00&nbsp;\u76ee\u5f55&nbsp;\uff0c\u8fdb\u5165&nbsp;package.nw&nbsp;\uff0c\u55ef\uff1f\u719f\u6089\u7684\u5473\u9053\u6765\u4e86\u3002\u91cc\u9762\u5c313\u4e2a\u6587\u4ef6\uff1aapp&nbsp;\uff0cnode_modules\uff0cpackage.json&nbsp;\u3002\u663e\u7136\u6211\u4eec\u5f00\u53d1\u65f6\u6784\u5efa\u9636\u6bb5\u6240\u7528\u8d44\u6e90\u6765\u81ea\u4e8e node_modules \uff0c\u4e8e\u662f\u6211\u5c1d\u8bd5\u627e\u4e0b&nbsp;react\u6a21\u5757\uff0c\u7ed3\u679c\u6ca1\u6709\u6536\u83b7&#8230; \u8fdb\u5165 app \u76ee\u5f55\u4e0b\uff0c\u5448\u73b0\u7684\u56db\u4e2a\u6587\u4ef6\u5939\u5206\u522b\u662f\uff1ahtml&nbsp;\uff0cstyle&nbsp;\uff0cimages&nbsp;\uff0cdist&nbsp;\u3002\u800c\u4f60\u5f00\u53d1\u65f6\u4f7f\u7528\u7684 IDE \u7684\u5b9e\u73b0\u6b63\u662f\u901a\u8fc7\u8fd9\u4e9b\u6587\u4ef6\uff0c\u4e0d\u59a8\u7528\u6d4f\u89c8\u5668\u6253\u5f00\u5176\u4e2d\u4e00\u4e2a html \u770b\u770b\u3002 \u8fd9\u4e0d\u5c31\u662f\u4ece\u684c\u9762\u6253\u5f00\u540e\u770b\u5230\u7684\u6548\u679c\u5417\uff08\u5176\u4e2d&nbsp;nodeWebkit&nbsp;\u63d0\u4f9b\u4e86 web \u5230\u684c\u9762\u5e94\u7528\u7684\u8f6c\u6362\uff09\u3002\u5e76\u4e14\u5728&nbsp;index.html&nbsp;\u4e2d\u627e\u5230\u6211\u4eec\u7684\u4e3b\u811a\u672c\u6587\u4ef6&nbsp;..\/dist\/app.js&nbsp;\uff0c\u6574\u4e2a IDE \u4ece\u7f16\u8f91\uff0c\u5f00\u53d1\uff0c\u9884\u89c8\uff0c\u53d1\u5e03\u7b49\u4e00\u7cfb\u5217\u64cd\u4f5c\u90fd\u5728 app.js \u53ca\u5176\u7684\u811a\u672c\u4e2d\u3002 2. \u903b\u8f91\u5173\u7cfb \u63a5\u4e0b\u6765\u5f00\u59cb\u5206\u6790\u4e0b&nbsp;dist&nbsp;\u4e0b\u6709\u4ec0\u4e48\u9b3c\u3002 \u4e0d\u8981\u6015\uff0c\u4e5f\u5c31\u51e0\u5341\u884c\u7684\u6e90\u7801\u3002 \u4e0d\u8fc7\u6bcf\u884c\u90fd\u662f\u538b\u7f29\u8fc7\u540e\u7684\u800c\u5df2&#8230;\u597d\u5427\uff0c\u4e22\u53bb\u53cd\u538b\u7f29\u4e00\u4e0b\u3002\u5728 Sublime Text3 \u4e2d\u88c5\u4e00\u4e2a&nbsp;jsmat&nbsp;\u7684\u63d2\u4ef6\uff0c\u5bf9\u8981\u683c\u5f0f\u5316\u7684\u4ee3\u7801\u8fdb\u884c Ctrl + Alt + F \u5373\u53ef\uff0c\u63a5\u4e0b\u6765\u5bf9\u6211\u4eec\u7684\u6587\u4ef6\u8fdb\u884c\u4e00\u4e2a\u903b\u8f91\u5212\u5206\u3002 \u663e\u7136\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f IDE \u672c\u8eab\u662f\u7528 React \u7ec4\u4ef6\u5e76\u4e14\u4ee5 Flux [&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-29969","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29969","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=29969"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29969\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}