下面是一个演示问题的代码片段:
import React from 'react'
import ReactDOM from 'react-dom'
class App extends React.Component {
render() {
return (
<div contentEditable="true">
<p>
<span onKeyDown={(e)=>{
alert("hello world!!")
}}>Hello world</span>
</p>
</div>
)
}
}
ReactDOM.render(
<App />,
document.getElementById('container')
);
专注于 div 并按下一些按钮后,警报未被触发。为什么?
https://codesandbox.io/embed/react-playground-forked-fymxg3?fontsize=14&hidenavigation=1&theme=dark