在我的 React 网络应用程序中,我有一个聊天功能,它是这样工作的:
我尝试使用此代码:
const event = new KeyboardEvent('keypress', {
keyCode: 13,
charCode: 35373,
bubbles: true
});
const success = textAreaRef.dispatchEvent(event);
if (success) {
console.log('Event was successfully dispatched');
} else {
console.log('Event was cancelled or prevented from being dispatched');
}
控制台显示事件已成功发送,但我仍然收到错误消息
请帮我解决这个问题,非常感谢!