我是初學(xué)者,仍在學(xué)習(xí)如何對(duì)本機(jī)做出反應(yīng)。在我的本機(jī)應(yīng)用程序中,我有 2 個(gè)屏幕。在第一頁(yè),我有 JSON 數(shù)據(jù) [從實(shí)時(shí)服務(wù)器獲取];我想將此 JSON 數(shù)據(jù)傳遞到下一頁(yè)。我使用 react-navigation 在頁(yè)面之間導(dǎo)航。我將一個(gè)數(shù)據(jù)[手機(jī)號(hào)碼] 傳遞到下一頁(yè)。但我想不通,如何將 JSON 數(shù)據(jù)傳遞到下一頁(yè)!第一頁(yè)代碼:[其中包含 JSON 數(shù)據(jù)]constructor(props) { super(props) this.state = { UserMNO: '' } } UserLoginFunction = () =>{ const { UserMNO } = this.state; const {firstname} = this.state; const {lastname} = this.state; const {email} = this.state; const {profession} =this.state;fetch('http://demo.weybee.in/react/User_Login.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ mobileno: UserMNO, })}).then((response) => response.json()) .then((responseJson) => { // If server response message same as Data Matched if(responseJson != 'Enter valid phone number' ) { console.log(responseJson[0]); console.log(responseJson[1]); console.log(responseJson[2]); console.log(responseJson[3]); //Then open Profile activity and send user email to profile activity. this.refs.toast.show('Login successful', 500, () => { const { navigation } = this.props; const { UserMNO } = this.state ; navigation.navigate("Profile", {mobileno : UserMNO}, ); }); } else{ Alert.alert(responseJson); } }).catch((error) => { console.error(error); }); }
在 React Native 中將 JSON 數(shù)據(jù)傳遞到下一頁(yè)
素胚勾勒不出你
2021-07-06 13:01:47