我正在嘗試在另一個 onClick 事件函數(shù)上觸發(fā)單擊按鈕。錯誤:未捕獲的類型錯誤:this.clickBack.current.click 不是函數(shù)React 版本是 16.8.6constructor(props) { super(props) this.clickBack = React.createRef(); this.startInterview = this.startInterview.bind(this);}startInterview(){ console.log('hello') // output : hello console.log(this.clickBack.current); // output : Button {props: {…}, context: {…}, refs: {…}, updater: {…}, onClick: ?, …} this.clickBack.current.click(); // output : Uncaught TypeError: this.clickBack.current.click is not a function}在渲染 -> 返回方法中<Link to={backLink}> <Button ref={this.clickBack}> Back</Button></Link><Button onClick={this.startInterview}> Start Interview</Button>
onClick 觸發(fā)單擊錯誤:current.click 不是函數(shù)
白板的微信
2021-08-20 10:32:32