亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

react 在 componentDidMount中的對象,在 handleSubmit 中使用?

react 在 componentDidMount中的對象,在 handleSubmit 中使用?

一只斗牛犬 2018-09-02 11:26:15
class Demo extends Component {     handleSubmit = () => {        // 如何在這個生命周期內使用 chart 對象          }     componentDidMount() {        // 構建變更大圖         var chart = new G2.Chart({             container: 'dashboardChange',             forceFit: true,         });     }     }
查看完整描述

2 回答

?
有只小跳蛙

TA貢獻1824條經驗 獲得超8個贊

你這樣寫不就可以了么

class Demo extends Component {
  handleSubmit = () => {    // 如何在這個生命周期內使用 chart 對象
  }
  componentDidMount() {    // 構建變更大圖
    this.chart = new G2.Chart({          container: 'dashboardChange',          forceFit: true,
    });
  }
}


查看完整回答
反對 回復 2018-09-02
?
青春有我

TA貢獻1784條經驗 獲得超8個贊

直接綁定在 Demo 這個 class 中不就可以了嗎

查看完整回答
反對 回復 2018-09-02
  • 2 回答
  • 0 關注
  • 1367 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號