第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在 React JS 中的兩個(gè)子組件之間傳輸數(shù)據(jù)?

如何在 React JS 中的兩個(gè)子組件之間傳輸數(shù)據(jù)?

POPMUISE 2023-02-24 16:50:54
實(shí)際上,我正在創(chuàng)建一個(gè)前端,在其中我將手機(jī)號(hào)碼作為第一頁(yè)的輸入,然后在檢查手機(jī)號(hào)碼后我將轉(zhuǎn)到 OTP 頁(yè)面。在 OTP 頁(yè)面中,我將 otp 作為輸入,并且必須將 otp 和手機(jī)號(hào)碼發(fā)送到后端。我可以通過(guò) otp,但不知道如何通過(guò)手機(jī)號(hào)碼,因?yàn)槲乙褜⑵渥鳛樯弦豁?yè)的輸入。這是注冊(cè)組件,它將接受手機(jī)號(hào)碼輸入import React from 'react';import './Signup.css';class Signup extends React.Component {    constructor(props){        super(props);        this.state={            mobile:''        }    }    onMobileChange = (event) => {        this.setState({mobile: event.target.value})    }    onSubmitSignup = () => {        fetch('https://cors-anywhere.herokuapp.com/http://8080/signup/checkMobile',{            method:'post',            headers:{'Content-Type':'application/json'},            body: JSON.stringify({                mobile:this.state.mobile            })        })        .then(response => response.json())        .then(data =>{            if(data.content === 'OK'){                this.props.loadNewUser(this.state.mobile);                this.props.onRouteChange('otp','nonav');            }        })        // this.props.onRouteChange('otp','nonav');    }    render(){        const { onRouteChange} = this.props;        return(            <div className='container'>                <div className='mt6'>                    <img src={require('./logo.png')} className='logoimg' alt='logo'/>                </div>                <h3 className='text-center b' style={{font:"Montserrat"}}>FOODVIRAAM</h3>                <div>
查看完整描述

2 回答

?
大話(huà)西游666

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊

使用localStorage或Cookies將您的電話(huà)號(hào)碼存儲(chǔ)在一頁(yè)和下一頁(yè)上,您可以通過(guò)您選擇的任何媒體輕松檢索數(shù)據(jù)。由于存儲(chǔ)在其中任何一個(gè)上都會(huì)保留您的數(shù)據(jù),因此您無(wú)需擔(dān)心頁(yè)面的意外刷新。


不要使用Reduxor Context API,因?yàn)樗鼈儾粫?huì)保留數(shù)據(jù)。


例子 :-


使用本地存儲(chǔ) API


// storing the phone number on your first page.

localStorage.setItem('$$NAMESPACE__phone_number', phoneNumber)


// getting the phone number on your second.

const phoneNumber = localStorage.getItem('$$NAMESPACE__phone_number')


查看完整回答
反對(duì) 回復(fù) 2023-02-24
?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

使用 Redux 它有點(diǎn)復(fù)雜但是當(dāng)你需要從孩子向父母?jìng)鬏敂?shù)據(jù)時(shí)使用它,你還可以獲取你通過(guò)道具發(fā)送給孩子的數(shù)據(jù)并獲得返回值

https://redux.js.org


查看完整回答
反對(duì) 回復(fù) 2023-02-24
  • 2 回答
  • 0 關(guān)注
  • 153 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)