You should pass arrow function as success callback for AJAX call inside onFormSubmit method to make sure that this inside this callback points to the component:onFormSubmit(id) { console.log("Started"); fetch("http://localhost:xxxx/api/Surveys/" + id + "/submit", { method:'POST' }) .then((response) => { ... })} 这篇关于(this)在react js回调中被识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 11:15