{"id":507,"date":"2023-02-25T14:23:11","date_gmt":"2023-02-25T06:23:11","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=507"},"modified":"2023-04-29T20:47:16","modified_gmt":"2023-04-29T12:47:16","slug":"react-native-learning-install-nuclide-and-alertios-apis","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/react-native-learning-install-nuclide-and-alertios-apis\/","title":{"rendered":"React Native\u5b66\u4e60\u4e4b\u5b89\u88c5Nuclide\u4e0eAlertIOS API"},"content":{"rendered":"<h2>Nuclide<\/h2>\n<p>\u5b89\u88c5Mac\u4e0bReact Native\u7684\u5f00\u53d1\u5de5\u5177Nuclide<\/p>\n<p>FaceBook\u5b98\u65b9\u63a8\u8350\uff1a<code>Nuclide<\/code><\/p>\n<p><!-- more --><\/p>\n<p>\u53ea\u652f\u6301Mac\uff0c\u57fa\u4e8eAtom\uff08Github\u7684\uff09\uff08Atom\u6700\u5927\u7684\u7279\u8272\u5c31\u662f\u53ef\u4ee5\u5b89\u88c5\u5f88\u591a\u7684\u63d2\u4ef6\u6765\u5b8c\u6210\u6211\u4eec\u7684\u9700\u6c42\uff09\u70ab\u9177\u63d2\u4ef6\u3002<\/p>\n<p>Atom\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/atom.io\/\">https:\/\/atom.io\/<\/a><br \/>\nNuclide\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/nuclide.io\/\">https:\/\/nuclide.io\/<\/a><br \/>\nNuclide\u5f00\u6e90\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/facebook\/nuclide\">https:\/\/github.com\/facebook\/nuclide<\/a><\/p>\n<p>\u9996\u5148\u5b89\u88c5Atom\uff0c\u7136\u540e\u5b89\u88c5Nuclide\uff1a<\/p>\n<pre><code>apm install nuclide<\/code><\/pre>\n<p>\u6253\u5f00atom\uff0c\u5982\u679cnuclide\u5b89\u88c5\u6210\u529f\uff0c\u5219\u53ef\u4ee5\u770b\u5230nuclide\u7684\u6b22\u8fce\u754c\u9762\u3002<\/p>\n<p>\u5982\u679c\u6253\u5f00nuclide\u51fa\u73b0\u95ee\u9898\uff0c\u9700\u8981\u5b89\u88c5flow\uff0c\u4e00\u4e2a\u9759\u6001\u7684\u5bf9js\u7c7b\u578b\u68c0\u67e5\u5668<\/p>\n<pre><code>brew install flow<\/code><\/pre>\n<p>\u8981\u60f3nuclide\u652f\u6301\u4ee3\u7801\u81ea\u52a8\u8865\u5168 \u9700\u8981\u5b89\u88c5\u4e24\u4e2a\u63d2\u4ef6\uff1a<\/p>\n<ul>\n<li><code>atom-react-native-css<\/code><\/li>\n<li><code>atom-react-native-autocomplete<\/code><\/li>\n<\/ul>\n<p>\u66f4\u65b0\u6240\u6709\u5de5\u5177\uff1a<\/p>\n<pre><code>brew update &amp;&amp; brew upgrade<\/code><\/pre>\n<p>\u63a8\u8350\u5b89\u88c5 Nuclide \u4ee3\u7801\u81ea\u52a8\u8865\u5168\u63d0\u793a\u7684\u63d2\u4ef6\uff1a<\/p>\n<ul>\n<li><code>atom-react-native-css<\/code><\/li>\n<li><code>atom-react-native-autocomplete<\/code><\/li>\n<\/ul>\n<p>Atom\u83dc\u5355 -&gt; Packages -&gt; Settings View -&gt; Open -&gt; \u5de6\u4fa7\u8fb9\u680f\u70b9\u51fb Install \u6807\u7b7e<\/p>\n<p>\u641c\u7d22\u5e76\u5b89\u88c5<code>atom-react-native-css<\/code>\u548c<code>atom-react-native-autocomplete<\/code><\/p>\n<p>Mac\u4e0b\u4fdd\u5b58\u5feb\u6377\u952e\uff1aMac\u771f\u673a(command+s) \uff0cWindows\u4e0bMac\u865a\u62df\u673a(win+s)\u3002\u4e5f\u53ef\u4ee5\u5b89\u88c5 Nuclide \u81ea\u52a8\u4fdd\u5b58\u4ee3\u7801\u7684\u63d2\u4ef6\uff1aautosave<\/p>\n<p>autosave \u5df2\u7ecf\u5b58\u5728\u4e8e\u6838\u5fc3\u5305 Core Packages \u4e2d\uff0c\u53ea\u9700\u8981 Setting enabled<\/p>\n<h2>AlertIOS<\/h2>\n<p>AlertIOS\u7684\u9759\u6001\u65b9\u6cd5\u6709\u4e24\u4e2a\uff1a<\/p>\n<ul>\n<li><code>alert(title, message, [] buttons)<\/code>\uff1a\u666e\u901a\u5bf9\u8bdd\u6846<\/li>\n<li><code>prompt(title, message, [] buttons)<\/code>\uff1a\u63d0\u4f9b\u8f93\u5165\u7684\u5bf9\u8bdd\u6846<\/li>\n<\/ul>\n<p>\u5982\u679cbuttons\u4e3a\u7a7a\u6570\u7ec4\uff0c\u9ed8\u8ba4\u4e5f\u4f1a\u6709\u4e00\u4e2aok\u6309\u94ae\uff0c\u5982\u679c\u6570\u636e\u7684\u957f\u5ea6\u8fc7\u957f\uff0c\u6309\u94ae\u5c31\u4f1a\u5782\u76f4\u6392\u5217\uff01<\/p>\n<pre><code class=\"language-javascript\">\/**\n * Sample React Native App\n * https:\/\/github.com\/facebook\/react-native\n * @flow\n *\/\n\nimport React, { Component } from &#039;react&#039;;\nimport {\n  AppRegistry,\n  StyleSheet,\n  Text,\n  View,\n  AlertIOS,\n} from &#039;react-native&#039;;\n\nclass RNAPP extends Component {\n    render() {\n        return (\n            &lt;View style={styles.container}&gt;\n                &lt;Text style={styles.item} onPress={this.tip}&gt;\u63d0\u793a\u5bf9\u8bdd\u6846&lt;\/Text&gt;\n                &lt;Text style={styles.item} onPress={this.input}&gt;\u8f93\u5165\u5bf9\u8bdd\u6846&lt;\/Text&gt;\n            &lt;\/View&gt;\n        );\n    }\n\n    tip() {\n        AlertIOS.alert(&#039;\u63d0\u793a&#039;, &#039;\u6b22\u8fce\u89c2\u4e34 React Native APP \u5f00\u53d1\u793e\u533a&#039;, [\n            {\n                text: &#039;\u53d6\u6d88&#039;,\n                onPress: () =&gt; {\n                    alert(&#039;\u60a8\u70b9\u51fb\u4e86\u53d6\u6d88\u6309\u94ae&#039;);\n                }\n            },\n            {\n                text: &#039;\u786e\u8ba4&#039;,\n                onPress: () =&gt; {\n                    alert(&#039;\u60a8\u70b9\u51fb\u4e86\u786e\u8ba4\u6309\u94ae&#039;);\n                }\n            },\n        ]);\n    }\n\n    input() {\n        AlertIOS.prompt(&#039;\u63d0\u793a&#039;, &#039;\u8bf7\u8f93\u5165\u60a8\u7684\u7528\u6237\u540d&#039;, [\n            {\n                text: &#039;\u53d6\u6d88&#039;,\n                onPress: () =&gt; {\n                    alert(&#039;\u60a8\u70b9\u51fb\u4e86\u53d6\u6d88\u6309\u94ae&#039;);\n                }\n            },\n            {\n                text: &#039;\u786e\u8ba4&#039;,\n                onPress: (text) =&gt; {\n                    alert(text);\n                }\n            },\n        ]);\n    }\n}\n\nconst styles = StyleSheet.create({\n    container: {\n        flex: 1,\n        marginTop:25,\n    },\n    item:{\n        marginTop:10,\n        marginLeft:5,\n        marginRight:5,\n        height:30,\n        borderWidth:1,\n        padding:6,\n        borderColor:&#039;#ddd&#039;,\n    }\n});\n\nAppRegistry.registerComponent(&#039;RNAPP&#039;, () =&gt; RNAPP);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nuclide \u5b89\u88c5Mac\u4e0bReact Native\u7684\u5f00\u53d1\u5de5\u5177Nuclide FaceBook\u5b98\u65b9\u63a8\u8350\uff1aNuc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[163],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-react-native"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}