{"id":1530,"date":"2023-08-02T09:38:22","date_gmt":"2023-08-02T01:38:22","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=1530"},"modified":"2023-08-02T09:38:22","modified_gmt":"2023-08-02T01:38:22","slug":"app%e5%8f%af%e4%bb%a5%e5%bc%80%e5%8f%91%e5%a4%9a%e9%a1%b5%e9%9d%a2%e5%ba%94%e7%94%a8%e5%90%97","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/1530\/","title":{"rendered":"app\u53ef\u4ee5\u5f00\u53d1\u591a\u9875\u9762\u5e94\u7528\u5417?"},"content":{"rendered":"

\u5f53\u7136\u53ef\u4ee5\uff01App\u5f00\u53d1\u53ef\u4ee5\u5b9e\u73b0\u591a\u9875\u9762\u5e94\u7528\uff0c\u8fd9\u662f\u901a\u8fc7\u4f7f\u7528\u4e0d\u540c\u7684\u9875\u9762\u548c\u9875\u9762\u95f4\u7684\u5bfc\u822a\u6765\u5b9e\u73b0\u7684\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u4e3a\u4f60\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u591a\u9875\u9762\u5e94\u7528\u3002<\/p>\n

\u5728\u5f00\u53d1\u591a\u9875\u9762\u5e94\u7528\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u7684\u6982\u5ff5\u3002\u9996\u5148\uff0c\u9875\u9762\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u57fa\u672c\u7ec4\u6210\u5355\u5143\u3002\u6bcf\u4e2a\u9875\u9762\u90fd\u6709\u81ea\u5df1\u7684\u5e03\u5c40\u548c\u529f\u80fd\u3002\u5176\u6b21\uff0c\u5bfc\u822a\u662f\u7528\u6237\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6d4f\u89c8\u4e0d\u540c\u9875\u9762\u7684\u65b9\u5f0f\u3002\u5bfc\u822a\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u6309\u94ae\u3001\u94fe\u63a5\u6216\u8005\u6ed1\u52a8\u5c4f\u5e55\u7b49\u65b9\u5f0f\u89e6\u53d1\u3002<\/p>\n

\u73b0\u5728\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528App\u5f00\u53d1\u5de5\u5177\u6765\u521b\u5efa\u4e00\u4e2a\u591a\u9875\u9762\u5e94\u7528\u3002\u6211\u4eec\u5c06\u4ee5React Native\u4e3a\u4f8b\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6\u3002<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5React Native\u7684\u5f00\u53d1\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u5728React Native\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0a\u627e\u5230\u8be6\u7ec6\u7684\u5b89\u88c5\u6307\u5357\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528React Native\u7684\u547d\u4ee4\u884c\u5de5\u5177\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u3002<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4f60\u559c\u6b22\u7684APP<\/a>\u4ee3\u7801\u7f16\u8f91\u5668\u6253\u5f00\u9879\u76ee\u6587\u4ef6\u5939\u3002\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\uff0c\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u540d\u4e3a`App.js`\u7684\u6587\u4ef6\uff0c\u8fd9\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u6587\u4ef6\u3002\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u7ec4\u4ef6\u3002<\/p>\n

\u5728\u6839\u7ec4\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528React Native\u63d0\u4f9b\u7684\u5bfc\u822a\u7ec4\u4ef6\u6765\u5b9e\u73b0\u9875\u9762\u5bfc\u822a\u3002\u4e00\u4e2a\u5e38\u7528\u7684\u5bfc\u822a\u7ec4\u4ef6\u662f`StackNavigator`\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u9875\u9762\u7684\u5806\u6808\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u5bfc\u822a\u65b9\u6cd5\u3002<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u5bfc\u5165`StackNavigator`\u7ec4\u4ef6\uff1a<\/p>\n

“`<\/p>\n

import { createStackNavigator } from ‘react-navigation’;<\/p>\n

“`<\/p>\n

\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u5b9a\u4e49\u4f60\u7684\u9875\u9762\u7ec4\u4ef6\uff1a<\/p>\n

“`<\/p>\n

class HomeS<\/p>\n

<\/figure>\n<\/p>\n

creen extends React.Component {<\/p>\n

render() {<\/p>\n

return (<\/p>\n

\n

Welcome to the Home Screen!<\/p>\n<\/p>\n

title=”Go to Details”<\/p>\n

onPress={() => this.props.navigation.navigate(‘Details’)}<\/p>\n

\/><\/p>\n<\/p>\n

);<\/p>\n

}<\/p>\n

}<\/p>\n

class DetailsScreen extends React.Component {<\/p>\n

render() {<\/p>\n

return (<\/p>\n

\n

Welcome to the Details Screen!<\/p>\n<\/p>\n

);<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u5bfc\u822a\u5668\uff0c\u5e76\u5c06\u9875\u9762\u7ec4\u4ef6\u4e0e\u5bfc\u822a\u5668\u8fdb\u884c\u5173\u8054\uff1a<\/p>\n

“`<\/p>\n

const AppNavigator = createStackNavigator({<\/p>\n

Home: { screen: HomeScreen },<\/p>\n

Details: { screen: DetailsScreen },<\/p>\n

});<\/p>\n

export default createAppContainer(AppNavigator);<\/p>\n

“`<\/p>\n

\u6700\u540e\uff0c\u4f60\u9700\u8981\u5728\u6839\u7ec4\u4ef6\u4e2d\u6e32\u67d3\u5bfc\u822a\u5668\uff1a<\/p>\n

“`<\/p>\n

class App extends React.Component {<\/p>\n

render() {<\/p>\n

return (<\/p>\n<\/p>\n

);<\/p>\n

}<\/p>\n

}<\/p>\n

const AppContainer = createAppContainer(AppNavigator);<\/p>\n

export default App;<\/p>\n

“`<\/p>\n

\u73b0\u5728\u4f60\u53ef\u4ee5\u8fd0\u884c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u9996\u9875\u70b9\u51fb\u6309\u94ae\u8df3\u8f6c\u5230\u8be6\u60c5\u9875\u9762\u4e86\uff01<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528React Native\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u591a\u9875\u9762\u5e94\u7528\u7684\u57fa\u672c\u6b65\u9aa4\u3002\u5f53\u7136\uff0c\u5b9e\u9645\u5f00\u53d1\u4e2d\u53efAPP\u5f00\u53d1<\/a>\u80fd\u6d89\u53ca\u5230\u66f4\u590d\u6742\u7684\u9875\u9762\u548c\u5bfc\u822a\u903b\u8f91\uff0c\u4f46\u8fd9\u4e2a\u4f8b\u5b50\u5e94\u8be5\u80fd\u5e2e\u52a9\u4f60\u5165\u95e8\u3002<\/p>\n

\u603b\u7ed3\u4e00\u4e0b\uff0c\u5f00\u53d1\u591a\u9875\u9762\u5e94\u7528\u9700\u8981\u4f7f\u7528\u5bfc\u822a\u7ec4\u4ef6\u6765\u7ba1\u7406\u9875\u9762\u4e4b\u95f4\u7684\u5207\u6362\u3002\u5728React Native\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528`StackNavigator`\u6765\u5b9e\u73b0\u5bfc\u822a\u3002\u901a\u8fc7\u521b\u5efa\u9875\u9762\u7ec4\u4ef6\u5e76\u5c06\u5176\u4e0e\u5bfc\u822a\u5668\u8fdb\u884c\u5173\u8054\uff0c\u4f60\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u591a\u9875\u9762\u5e94\u7528\u3002<\/p>\n

\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5e2e\u52a9\u4f60\u7406\u89e3\u591a\u9875\u9762\u5e94\u7528\u7684\u5f00\u53d1\u539f\u7406\u548c\u57fa\u672c\u6b65\u9aa4\u3002\u5982\u679c\u4f60\u6709\u4efb\u4f55\u95ee\u9898\u6216\u8005\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u5e2e\u52a9\uff0c\u8bf7\u968f\u65f6\u63d0\u95ee\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5f53\u7136\u53ef\u4ee5\uff01App\u5f00\u53d1\u53ef\u4ee5\u5b9e\u73b0\u591a\u9875\u9762\u5e94\u7528\uff0c\u8fd9\u662f\u901a\u8fc7\u4f7f\u7528\u4e0d\u540c\u7684\u9875\u9762\u548c\u9875\u9762\u95f4\u7684\u5bfc\u822a\u6765\u5b9e\u73b0\u7684\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u4e3a\u4f60\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5f00\u53d1\u4e00\u4e2a\u591a\u9875\u9762\u5e94\u7528\u3002\u5728\u5f00\u53d1\u591a\u9875\u9762\u5e94\u7528\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u7684\u6982\u5ff5\u3002\u9996\u5148\uff0c\u9875\u9762<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[3360,27,3359,736,361],"topic":[],"class_list":["post-1530","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-window-exe","tag-27","tag-app","tag-736","tag-361"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/1530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=1530"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}