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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用map時,Reaction‘無法讀取未定義的屬性’

使用map時,Reaction‘無法讀取未定義的屬性’

我正在做一個很基本的應(yīng)用程序,我經(jīng)常會遇到“TypeError:無法讀取未定義的屬性‘onPlayerScoreChange’”即使我正確地綁定了我的函數(shù)(我認(rèn)為)'onPlayerScoreChange'是Grandparent組件,當(dāng)用戶單擊“+”或“-”按鈕以更改玩家的得分時執(zhí)行。如果有人能解釋一下是怎么回事會很有幫助,因為我想我是在this.onPlayerScoreChange = this.onPlayerScoreChange.bind(this)在曾祖父的構(gòu)造函數(shù)中。父組件:class App extends React.Component {constructor(props) {     super(props);     this.onPlayerScoreChange = this.onPlayerScoreChange.bind(this)     this.state = {         initialPlayers: props.initialPlayers,     };}onPlayerScoreChange(delta, index) {     this.setState((prevState, props) => {         return {initialPlayers: this.prevState.initialPlayers[index].score += delta}     })}render() {     return(         <div className = "scoreboard">             <Header title = {this.props.title}/>             <div className = "players">                 {this.state.initialPlayers.map(function(player, index) {                     return(                         <Player                          name = {player.name}                          score = {player.score}                          key = {player.id}                          index = {index}                         onScoreChange = {this.onPlayerScoreChange}                         />                     )                 })}             </div>         </div>     )}}(組件具有默認(rèn)標(biāo)題支持)兒童部分:class Player extends React.Component {render() {     return(         <div className = "player">             <div className = "player-name">                 {this.props.name}             </div>             <div className = "player-score">                 <Counter score = {this.props.score} onChange = {this.props.onScoreChange} index = {this.props.index}/>             </div>         </div>)}}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 1061 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

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

公眾號

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