我需要historyUndo從historyRedo. InputEvent問題是,我的contentEditablediv 沒有給FormEvent我InputEvent。
const inputChanged = (e: InputEvent) => {
//Error here because e is FormEvent type not InputEvent
if(e.inputType === 'historyUndo' || e.inputType === 'historyRedo')
{
....
}
}
return <div contentEditable={true} onInput={(e) => inputChanged(e)}>
....
</div>
我怎樣才能InputEvent了解 div contentEditable?
uj5u.com熱心網友回復:
您要做的是訪問nativeEvent事件的屬性。類似的東西。
const inputChanged = (e) => {
if(e.nativeEvent.inputType === 'historyUndo' || e.nativeEvent.inputType === 'historyRedo')
{
....
}
}
return <div contentEditable={true} onInput={(e) => inputChanged(e)}>
....
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/493163.html
標籤:javascript html 反应 打字稿
