Reactjs &引用;这";不允许在使用模型时使用。确认()

Reactjs &引用;这";不允许在使用模型时使用。确认(),reactjs,Reactjs,我正在处理react js并从库中导入确认模式,但它不允许我在onOk()方法中使用“this” 试试这个: confirm({ title: 'Are you sure you want to delete this measureemnt?', okText: 'Yes', okType: 'danger', cancelText: 'No', onOk: (id) => this.deleteajax(id) }) 您需要

我正在处理react js并从库中导入确认模式,但它不允许我在onOk()方法中使用“this”

试试这个:

confirm({
     title: 'Are you sure you want to delete this measureemnt?',
     okText: 'Yes',
     okType: 'danger',
     cancelText: 'No',
     onOk: (id) => this.deleteajax(id)
     })

您需要使用一个arrow函数。可能的重复在堆栈溢出上有很多很多问题,关于
这个
在回调函数中未定义。您研究过哪些问题,尝试过哪些解决方案,为什么没有成功?
confirm({
     title: 'Are you sure you want to delete this measureemnt?',
     okText: 'Yes',
     okType: 'danger',
     cancelText: 'No',
     onOk: (id) => this.deleteajax(id)
     })