import { useRequest } from 'ahooks';
import { getList } from '../../service/home';
export default function Home() {
const { run, loading } = useRequest(getList, {
manual: true,
onSuccess: (res) => {
console.log(res);
}
})
; const fq = () => {
run();
}
return (
<div>
Home222
<button onClick={fq}>按钮</button>
</div>
)
} //设置了manual:true则需要手动调用run方法,如果不设置的话则组件加载后自动调用