You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
463 B
28 lines
463 B
// 函数组件的创建和渲染
|
|
// 创建
|
|
function Hello() {
|
|
// 定义事件回调函数
|
|
const clickHandle = (e) => {
|
|
// 阻止默认行为
|
|
e.preventDefault()
|
|
alert('函数组件中的事件被触发了')
|
|
}
|
|
// 事件绑定
|
|
return (
|
|
<div>
|
|
<a onClick={clickHandle} href="https://123.sogou.com/">
|
|
搜狗
|
|
</a>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<div>
|
|
<Hello />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default App
|