为了账号安全,请及时绑定邮箱和手机立即绑定

onClick 触发单击错误:current.click 不是函数

onClick 触发单击错误:current.click 不是函数

白板的微信 2021-08-20 10:32:32
我正在尝试在另一个 onClick 事件函数上触发单击按钮。错误:未捕获的类型错误:this.clickBack.current.click 不是函数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>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 318 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信