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.
30 lines
763 B
30 lines
763 B
/**
|
|
* 类组件发送网络请求:
|
|
* 生命周期钩子函数:componentDidMount;执行时机:在初始化的时候 dom 渲染完毕时只执行一次
|
|
*/
|
|
|
|
/**
|
|
* 1.不加依赖项,执行时机:初始化 + 重新渲染
|
|
* 2.加 [] , 执行时机:初始化执行一次
|
|
* 3.加特定的依赖项 [count, name] ,执行时机:首次执行 + 任意一个变化执行
|
|
*/
|
|
|
|
import { useEffect } from 'react'
|
|
|
|
function App () {
|
|
useEffect(() => {
|
|
// 发送请求
|
|
async function loadData () {
|
|
const res = await fetch('http://geek.itheima.net/v1_0/channels')
|
|
console.log(res)
|
|
}
|
|
loadData()
|
|
}, [])
|
|
|
|
return (
|
|
<div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default App
|