Estoy usando reaccionar para escribir una interfaz de usuario web, cuando estoy usando este código para invocar una función handleSearchInfo en el bloque de procesamiento:
render(){ const props = { beforeUpload: file => { console.log(file.type) const isXls = (file.type === 'application/vnd.ms-excel') || (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); if (!isXls) { message.error('only support Excel'); return false; } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { message.error('less than 2MB!'); return false; } return isXls ? true : Upload.LIST_IGNORE; }, name: 'file', action: 'https://api.example.com/zhuolian/word/import', headers: { authorization: JSON.parse(localStorage.getItem('User')).token, }, onChange(info) { if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } if (info.file.status === 'done') { message.success(`${info.file.name} file uploaded successfully`); this.handleSearchInfo(); } else if (info.file.status === 'error') { message.error(`${info.file.name} file upload failed.`); } }, }; } me dice TypeError: Cannot read properties of undefined (reading 'handleSearchInfo') , cuando uso const that = this; luego, usando eso para invocar la función, funciona. ¿Por qué debería necesitar usar that para acceder a la función? ¿Por qué no podría usar this + function directamente?