{"id":20464,"date":"2024-01-04T11:06:27","date_gmt":"2024-01-04T03:06:27","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=20464"},"modified":"2024-01-04T11:06:27","modified_gmt":"2024-01-04T03:06:27","slug":"reactnative%e5%bc%80%e5%8f%91%e5%ae%89%e5%8d%93app%e6%93%8d%e4%bd%9c%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaapp\/20464\/","title":{"rendered":"reactnative\u5f00\u53d1\u5b89\u5353app\u64cd\u4f5c\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>React Native\u662f\u4e00\u79cd\u7528JavaScript\u7f16\u5199\u624b\u673a\u5e94\u7528\u7684\u6846\u67b6\u3002\u5b83\u662fReact\u7684\u4e00\u4e2a\u6269\u5c55\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u601d\u60f3\u6765\u5f00\u53d1iOS\uff0cAndroid\u548cWeb\u5e94\u7528\u3002React Native\u63d0\u4f9b\u4e86\u4e00\u79cd\u53ef\u91cd\u7528\u7684UI\u5143\u7d20\uff0c\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u4f7f\u7528\uff0c\u5982\u6309\u94ae\uff0c\u8f93\u5165\u6846\uff0c\u6587\u672c\u89c6\u56fe\u7b49\uff0c\u8fd9\u4f7f\u5f97\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u66f4\u52a0\u7b80\u5355\u548c\u5feb\u901f\u3002<\/p>\n<p>React Native\u5f00\u53d1\u5b89\u5353App\u7684\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u5b89\u88c5Node.js\u548cnpm<\/p>\n<p>React Native\u4f7f\u7528Node.js\u548cnpm\u6765\u7f16\u8bd1\u548c\u6784\u5efa<a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app\u5236\u4f5c<\/a>\u5e94\u7528\u7a0b\u5e8f\u3002\u5b89\u88c5Node.js\u548cnpm\u53ef\u4ee5\u4eceNode.js\u7f51\u7ad9\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002<\/p>\n<p>2. \u5b89\u88c5React Native\u547d\u4ee4\u884c\u5de5\u5177<\/p>\n<p>React Native\u63d0\u4f9b\u4e86\u4e00\u7ec4\u547d\u4ee4\u884c\u5de5\u5177\u6765\u521b\u5efa\uff0c\u542f\u52a8\u548c\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5React Native\u547d\u4ee4\u884c\u5de5\u5177\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install -g react-native-cli<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u521b\u5efa\u65b0\u7684React <a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app<\/a>Native\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u4f7f\u7528React Native\u547d\u4ee4\u884c\u5de5\u5177\u53ef\u4ee5\u521b\u5efa\u65b0\u7684React Native\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>react-native init MyApp<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c`MyApp`\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3002\u8fd9\u4e2a\u547d\u4ee4\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`MyApp`\u7684\u76ee\u5f55\uff0c\u5e76\u751f\u6210React Native\u5e94\u7528\u7a0b\u5e8f\u7684\u521d\u59cb\u4ee3\u7801\u3002<\/p>\n<p>4. \u8fde\u63a5Android\u8bbe\u5907\u6216\u542f\u52a8\u6a21\u62df\u5668<\/p>\n<p>\u5728Android\u8bbe\u5907\u4e0a\u8fd0\u884cReact Native\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u8fde\u63a5\u8bbe\u5907\u5230\u7535\u8111\uff0c\u6216\u8005\u5728\u7535\u8111\u4e0a\u542f\u52a8\u6a21\u62df\u5668\u3002\u53ef\u4ee5\u4f7f\u7528Android Studio\u6765\u542f\u52a8\u6a21\u62df\u5668\u6216\u8fde\u63a5\u8bbe\u5907\u3002<\/p>\n<p>5. \u542f\u52a8\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u8fdb\u5165\u5230\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u5f55\uff0c\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>react-native run-android<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u7f16\u8bd1React Native\u5e94\u7528\u7a0b\u5e8f\u7684JavaScript\u4ee3\u7801\uff0c\u5e76\u5728\u8fde\u63a5\u7684\u8bbe\u5907\u6216\u542f\u52a8\u7684\u6a21\u62df\u5668\u4e0a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>6. \u7f16\u5199React Native\u4ee3\u7801<\/p>\n<p>\u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u770b\u5230\u5b83\u5305\u542b\u4e86\u4e00\u4e2a\u57fa\u672c\u7684React Native\u754c\u9762\u3002\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4fee\u6539\u4ee3\u7801\u6765\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>React Native\u4f7f\u7528JavaScript\u7f16\u5199UI\uff0c\u53ef\u4ee5\u76f4\u63a5\u7f16\u8f91JavaScript\u6587\u4ef6\u6765\u66f4\u6539UI\u3002\u4f8b\u5982\uff0c\u5728`App.js`\u6587\u4ef6\u4e2d\uff0c\u4fee\u6539\u4ee3\u7801\u6765\u66f4\u6539UI\uff1a<\/p>\n<p>&#8220;`jsx<\/p>\n<p>import React from &#8216;react&#8217;;<\/p>\n<p>import { StyleSheet, Text, View } from &#8216;react-native&#8217;;<\/p>\n<p>export default function App() {<\/p>\n<p>  return (<\/p>\n<p>\n<p>      Hello, React Native!<\/p>\n<\/p>\n<p>  );<\/p>\n<p>}<\/p>\n<p>const styles = StyleSheet.create({<\/p>\n<p>  container: {<\/p>\n<p>    flex:<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/ag\/8\/sucai\/29.jpg\" \/><\/figure>\n<\/p>\n<p> 1,<\/p>\n<p>    backgroundColor: &#8216;#fff&#8217;,<\/p>\n<p>    alignItems: &#8216;center&#8217;,<\/p>\n<p>    justifyContent: &#8216;center&#8217;,<\/p>\n<p>  },<\/p>\n<p>  text: {<\/p>\n<p>    fontSize: 24,<\/p>\n<p>    color: &#8216;blue&#8217;,<\/p>\n<p>  },<\/p>\n<p>});<\/p>\n<p>&#8220;`<\/p>\n<p>7. \u8c03\u8bd5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>React Native\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u6765\u8c03\u8bd5JavaScript\u4ee3\u7801\u548cUI\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528`adb logcat`\u547d\u4ee4\u6765\u67e5\u770b\u65e5\u5fd7\u3002\u540c\u65f6\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528Chrome\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177\u8fdb\u884c\u8fdc\u7a0b\u8c03\u8bd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7528React Native\u5f00\u53d1\u5b89\u5353App\u7684\u57fa\u672c\u6b65\u9aa4\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cReact Native\u5f00\u53d1\u5b89\u5353App\u9700\u8981\u719f\u7ec3\u638c\u63e1JavaScript\u548cReact\uff0c\u5bf9\u4e8e\u65b0\u624b\u6765\u8bf4\u9700\u8981\u66f4\u591a\u7ec3\u4e60\u548c\u5b66\u4e60\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React Native\u662f\u4e00\u79cd\u7528JavaScript\u7f16\u5199\u624b\u673a\u5e94\u7528\u7684\u6846\u67b6\u3002\u5b83\u662fReact\u7684\u4e00\u4e2a\u6269\u5c55\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u601d\u60f3\u6765\u5f00\u53d1iOS\uff0cAndroid\u548cWeb\u5e94\u7528\u3002React Native\u63d0\u4f9b\u4e86\u4e00\u79cd\u53ef\u91cd\u7528<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[298,1008,25667,84,25666],"topic":[],"class_list":["post-20464","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-298","tag-1008","tag-app","tag-84"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=20464"}],"version-history":[{"count":1,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20464\/revisions"}],"predecessor-version":[{"id":20498,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/20464\/revisions\/20498"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=20464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=20464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=20464"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=20464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}