我是初學者,仍在學習如何對本機做出反應。在我的本機應用程序中,我有 2 個屏幕。在第一頁,我有 JSON 數據 [從實時服務器獲取];我想將此 JSON 數據傳遞到下一頁。我使用 react-navigation 在頁面之間導航。我將一個數據[手機號碼] 傳遞到下一頁。但我想不通,如何將 JSON 數據傳遞到下一頁!第一頁代碼:[其中包含 JSON 數據]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 數據傳遞到下一頁
素胚勾勒不出你
2021-07-06 13:01:47